CodeIgniter中的FCKeditor的路径问题

CodeIgniter默认的根目录是index.php所在的目录。把 fckeditor放在了根目录下(index.php所在的目录),之后看以下代码:

 

在  application/models 下建立一个公用的取得FCK的模:editor.php ,如下:

 

    function get_editor($name = 'content', $value = '', $toolbar = 'Default'){

        $this->load->file('editor/fckeditor.php'); // 目录
        $sBasePath = 'editor/';
       
        $editor = new FCKeditor($name);
        $editor->BasePath   = $sBasePath;
        $editor->ToolbarSet  = $toolbar; //Basic,Default
        $editor->Width  = '90%';
        $editor->Height = '300';
        $editor->Value  = $value;
       
        return $editor;
    }

//  说明:  $name是 fck 的名,也就是用$_post['content']来获取fck的值

 

1. 首先设置自动加载,因为这个是公用的! 找到根目录(index.php所在的目录)找到 application/config/autoload.php 文件,第111行(以我的文档为准,O(∩_∩)O哈哈~),修改:

 

$autoload['model'] = array('editor');

 

2.然后在控制器中写入如下代码:

$data['editor']  = $this->editor->get_editor(); // 当然你也可以通过设置参数来达到你想要的意图,比如可以通过设置第二个参数来显示fck的默认内容,这个在后台修改显示的时候很有用。
 

3.最后在视图中写入代码:

<div><?=$editor->create()?></div>

ok,设置成功,最后附上我已经设置好的fck,精简到1.45mb,而且它的上传路径是自动调整的,默认为editor同级目录下的files文件夹,不用再麻烦你动手设置了....

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值