cakephp2 中cteditor(fcteditor)

本文详细介绍如何在CakePHP项目中集成CKEditor富文本编辑器,包括精简CKEditor、上传文件、配置辅助类以及在视图中使用等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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转义问题

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值