cakephp2 中cteditor(fcteditor)

来源:互联网 发布:美工常用网站 编辑:程序博客网 时间:2024/05/19 02:18

cteditor版本ckeditor_3.6.3,

1、对解压后的ckeditor进行精简:去除多余的语言,除en,zh-cn,zh 去除例子,及源码,去除,asp

2、上传ckeditor到webroot/js/ckeditor

3、将ckeditor中php文件复制到Vendor文件夹

3、编写Fck助手:在view/helper/新建 FckHelper.php其内容如下:

<?php
App::import('Vendor', 'ckeditor');

class FckHelper extends AppHelper {
              
    /**
    * creates an fckeditor textarea
    *
    * @param array $namepair - used to build textarea name for views, array('Model', 'fieldname')
    * @param stirng $basepath - base path of project/system
    * @param string $content
    */
    function Fckeditor($namepair = array(), $basepath = '', $content = array()){
        $editor_name = 'data';
        foreach ($namepair as $name){
            $editor_name .= "[" . $name . "]";
        }

        $oFCKeditor = new CKEditor() ;
       $oFCKeditor->basePath = $basepath . '/js/ckeditor/' ;
        $oFCKeditor->config['width'] = "100%";
        $oFCKeditor->config['height'] = "400";    
        $oFCKeditor->editor($editor_name, $content);         
    }     

?>
4、对应contrllor中添加助手Fck;

5、view中用<?php echo $this->Fck->fckeditor(array('Article', 'content'),'','');?>article指model  content指对应字段,第二个参数指响应路径,第三个为变量 添加文件时为空,编辑时为对应set回变量对应字段。

6、注意html转义问题

 

 

原创粉丝点击