Codeigniter集成FCK简单方法

呵呵,在网上看到CI集成FCKeditor有很多方法,有把FCKeditor写成插件,然后用$this->load->plugin('')调用.还有直接成扩展类库文件的.呵呵,不过都还是很繁琐的,看到有人施了一小计觉得挺简单方便的直接写了以个Model问题就解决了.来看程序吧:
<?php   if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class O_editor extends Model
{
     function O_editor()
     {
         parent::Model();
     }
     function fckeditor($name, $value='', $toolbar='Default')
     {
         $editer_dir = 'fckeditor/'; //此处表示index.php同级目录下fckeditor,当然你也可以设置你自己喜欢的路径
        
         include $editer_dir.'fckeditor.php'; //".php"不建议替换为“EXT”
         $sBasePath = $editer_dir;
        
         $oFCKeditor = new FCKeditor($name);
         $oFCKeditor->BasePath     = $editer_dir;
         $oFCKeditor->ToolbarSet = $toolbar; //Basic,Default
         $oFCKeditor->Value = $value;
         $oFCKeditor->Height = 460;
         $oFCKeditor->Width = "100%";
        
         return $oFCKeditor;
     }
}
?>
---------------------------------------------------
Controller层调用方法:
---------------------------------------------------
$this->load->model('o_editor');
$data['editor1'] = $this->o_editor->fckeditor('content1');
$data['editor2'] = $this->o_editor->fckeditor('content2');
$data['editor3'] = $this->o_editor->fckeditor('content3');
---------------------------------------------------

VIEW页:
---------------------------------------------------
$editor1->Height = 320;
echo $editor1->Create();
$editor2->Height = 500;
echo $editor2->Create();
$editor3->Height = 300;
echo $editor3->Create();
---------------------------------------------------
OK好了 一下三个在线编辑器就出来了.

你可能感兴趣的:(CodeIgniter,职场,休闲,FCK)