phpcms 9.6多编辑器字段,一键增加任意多编辑器

有时候我们需要在后台需要增加任意多个编辑器,比如旅游网站需要增加旅游天数,每条旅游线路的天数不一样,这就需要我们可以自由控制编辑器数量,亦或者做人物简介,需要增加N多个生平轶事,都需要用到多编辑器效果。效果如图:

(为了截图效果,我把编辑器高度调成100了,自己可以随时调整)

有了这个字段,我们就可以随心所欲的去搞旅游类网站的线路管理了

注意:目前只支持官方默认的ckeditor,如果你改成其他版本的编辑器了,暂时不支持,另外目前不支持v10版本。

安装使用流程

(1)下载字段editors,放到你的目录phpcms\modules\content\fields下

(2)找到phpcms\modules\content\fields\fields.inc.php文件,在

'editor'=>'编辑器',

新增代码:

'editors'=>'多编辑器',

在最下边的可以追加 JS和CSS 的字段,添加新的字段'editors'

(3)找到phpcms\libs\classes\form.class.php文件,找到editor方法,在下边新增方法:

/** 
     * 多编辑器 
     */ 
    public static function editors($name,$field,$value = '',$catid=0) { 
        $str = ''; 
        $length = 0; 
        if($value){ 
            $value = string2array(html_entity_decode($value,ENT_QUOTES)); 
            if(is_array($value)) { 
                foreach($value as $k => $v){ 
                    $value[$k]['title'] = stripslashes($value[$k]['title']); 
                    $value[$k]['content'] = stripslashes($value[$k]['content']); 
                } 
                $length = count($value); 
                for($i=0; $i< $length; $i++){ 
                    $index = $i + 1; 
                    $str .= "<div style='margin:5px 0;line-height:25px'><span>分段标题".$index.":</span><input type='text' value='".$value[$i]['title']."' name='".$name."[title][]' style='width:400px;'></div>"; 
                    $str .= '<textarea class="class_'.$field.'" name="'.$name.'[content][]" id="'.$field.'_'.$i.'" boxid="'.$field.'_'.$i.'" >'.$value[$i]['content'].'</textarea>'; 
                } 
            } 
        } 
        $toolbar = "[['Source'],['Cut','Copy','Paste','PasteText','PasteFromWord','-'],['Bold','Italic','Underline','Strike','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Find','Replace','-','SelectAll','RemoveFormat'],['Link','Unlink','Image','Capture','video','Anchor'],['Styles','Format','Font','FontSize'], ['TextColor','BGColor']]"; 
        $height  = 200; 
        $disabled_page = 1; 
        $uploadUrl = "index.php?m=attachment&c=attachments&a=upload&module=content&catid=".$catid."&dosubmit=1"; 
         
        if($length == 0){ 
            $index = $length + 1; 
            $str .= "<div style='margin:5px 0;line-height:25px'><span>分段标题".$index.":</span><input type='text' value='' name='".$name."[title][]' style='width:400px;'></div>"; 
            $str .= '<textarea class="class_'.$field.'" name="'.$name.'[content][]" id="'.$field.'_'.$length.'" boxid="'.$field.'_'.$length.'"></textarea>'; 
        } 
        $str .= "<div id='addeditor_".$field."'></div>"; 
         
        ....//部分代码省略

        $str .= '<input type="button" class="button" id="btn_'.$field.'" value="+添加编辑器" style="margin-top:10px" onclick="add'.$field.'(\''.$field.'\')">'; 
        return $str; 
    } 

(4)更新全站缓存,增加字段,选择多编辑器字段,测试效果即可,如有需要可以留言或者doc.tengcee.com/other/259.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值