用户
 找回密码
 入住 CI 中国社区
搜索
查看: 14963|回复: 15
收起左侧

[插件 Plugin] 为CodeIgniter(v1.6.3) 安装FCKeditor插件

  [复制链接]
发表于 2008-10-15 16:47:47 | 显示全部楼层 |阅读模式
一篇博客中很好的文章,原文:http://blog.sina.com.cn/s/blog_4b93170a0100b1e4.html



1. 下载解压FCKeditor 2.6.x, 然后放在system/application/plugins/fckeditor/ 下。

2.根据你的php版本,将fckeditor_php4.php或fckeditor_php5.php复制到 /system/application/libraries/ 下,并更名为 fckeditor.php

3. 打开此文件,将类名更改为 Fckeditor,并修改你的构造器
PHP复制代码
 
// PHP 5
    function __construct( $instanceName )
     {
        $this->InstanceName    = $instanceName ;
        $this->BasePath        = '/fckeditor/' ;
        $this->Width        = '100%' ;
        $this->Height        = '200' ;
        $this->ToolbarSet    = 'Default' ;
        $this->Value        = '' ;
        $this->Config        = array() ;
    }
// PHP 4
    function Fckeditor( $instanceName )
    {
        $this->__construct( $instanceName ) ;
    }
 
 
复制代码

4. 打开 ./system/application/libraries/下的 fckeditor.php,复制FCKeditor_IsCompatibleBrowser()函数里的所有内容,替换到IsCompatible()函数里的所有内容

5. 修改 ./system/application/libraries/fckeditor.php 的 constructor 里的 basepath 定义
      $this->BasePath = base_url().'system/application/plugins/fckeditor/'  ;

6.如果你使用了.htaccess文件,需要做如下修改
   RewriteCond $1 !^(index\.php|images|system/application/plugins/fckeditor)



7. 基本设置完毕,在控制器中调用:
PHP复制代码
      $this->load->library('fckeditor','content');
        $this->fckeditor->ToolbarSet = 'Basic';
        $data['fckeditor']=$this->fckeditor->CreateHtml();
 
 
复制代码

   在view里用 <?=$fckeditor?>就可以了

8.如果要在一个页面显示多个fckeditor

PHP复制代码
 
 
$this->load->library('fckeditor', 'FCKEDITOR1');
 
$this->fckeditor->BasePath = 'system/plugins/FCKeditor/';
$this->fckeditor->ToolbarSet = 'Basic';
 
$data['fck1'] = $this->fckeditor->CreateHtml();
       
$this->fckeditor->InstanceName = 'FCKEDITOR2';
       
$data['fck2'] = $this->fckeditor->CreateHtml();
 
$this->load->view('mypage', $data);
 
//在服务器端,可以这样:
$first_box = $this->input->post('FCKEDITOR1');
$second_box = $this->input->post('FCKEDITOR2');
 
 
复制代码

其他的一些配置,你可以在fckconfig.js中自己修改

[ 本帖最后由 杏糖兜油菜 于 2008-10-15 22:28 编辑 ]

评分

参与人数 2威望 +10 收起 理由
oraclelee + 5
Hex + 5 原创内容

查看全部评分

发表于 2008-10-15 17:10:05 | 显示全部楼层
太好了!很多人都不会配置 FCKEditor,楼主是好人!加分
发表于 2008-10-15 17:37:12 | 显示全部楼层
发表于 2008-10-15 21:48:47 | 显示全部楼层
发表于 2008-10-17 17:05:50 | 显示全部楼层
FCK是个好东东,不过感觉还是用js调用来的实在,个人之见,仅供参考
发表于 2008-11-9 15:01:50 | 显示全部楼层
我想怎么看着那么眼熟,原来那篇blog是抄的我的帖子:

http://codeigniter.org.cn/forums/viewthread.php?tid=259
发表于 2008-11-9 21:08:13 | 显示全部楼层
严厉打击抄袭帖子的行为!
发表于 2008-11-16 10:25:46 | 显示全部楼层
hex     就事论事啊!
发表于 2009-1-28 04:39:03 | 显示全部楼层
不负责任的抄袭行为,论坛的都试过,除了js的外其他都是不行的,楼主有心的就把配置好FCK的CI打包让我们下载。
发表于 2009-2-1 18:04:45 | 显示全部楼层
挺好
学习了
很强大
呵呵
谢谢

本版积分规则