`
天梯梦
  • 浏览: 13636810 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

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文件夹,不用再麻烦你动手设置了....

2
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics