QQ咨询 官方微信

添加微信好友

官方小程序

百度小程序

微信小程序

头条小程序

关于我们

PHPCMS

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

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


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


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

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

安装使用流程

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

(2)找到phpcms\modules\content\fields\fields.inc.php文件,在
  1. 'editor'=>'编辑器'
新增代码:
  1. 'editors'=>'多编辑器'
在最下边的可以追加 JS和CSS 的字段,添加新的字段'editors'

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

  1. /** 
  2.      * 多编辑器 
  3.      */ 
  4.     public static function editors($name,$field,$value = '',$catid=0) { 
  5.         $str = ''
  6.         $length = 0; 
  7.         if($value){ 
  8.             $value = string2array(html_entity_decode($value,ENT_QUOTES)); 
  9.             if(is_array($value)) { 
  10.                 foreach($value as $k => $v){ 
  11.                     $value[$k]['title'] = stripslashes($value[$k]['title']); 
  12.                     $value[$k]['content'] = stripslashes($value[$k]['content']); 
  13.                 } 
  14.                 $length = count($value); 
  15.                 for($i=0; $i< $length; $i++){ 
  16.                     $index = $i + 1; 
  17.                     $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>"; 
  18.                     $str .= '<textarea class="class_'.$field.'" name="'.$name.'[content][]" id="'.$field.'_'.$i.'" boxid="'.$field.'_'.$i.'" >'.$value[$i]['content'].'</textarea>'
  19.                 } 
  20.             } 
  21.         } 
  22.         $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']]"
  23.         $height  = 200; 
  24.         $disabled_page = 1; 
  25.         $uploadUrl = "index.php?m=attachment&c=attachments&a=upload&module=content&catid=".$catid."&dosubmit=1"
  26.          
  27.         if($length == 0){ 
  28.             $index = $length + 1; 
  29.             $str .= "<div style='margin:5px 0;line-height:25px'><span>分段标题".$index.":</span><input type='text' value='' name='".$name."[title][]' style='width:400px;'></div>"
  30.             $str .= '<textarea class="class_'.$field.'" name="'.$name.'[content][]" id="'.$field.'_'.$length.'" boxid="'.$field.'_'.$length.'"></textarea>'
  31.         } 
  32.         $str .= "<div id='addeditor_".$field."'></div>"
  33.          
  34.         ....//部分代码省略 
  35.  
  36.         $str .= '<input type="button" class="button" id="btn_'.$field.'" value="+添加编辑器" style="margin-top:10px" onclick="add'.$field.'(\''.$field.'\')">'
  37.         return $str; 
  38.     } 

(4)更新全站缓存,增加字段,选择多编辑器字段,测试效果即可

该插件属于付费插件,详情可查看:https://doc.tengcee.com/other/259.html
¥ 打赏
×
如果您觉得文章帮助了您就打赏一下吧
非常感谢你的打赏,我们将继续分享更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

本文《phpcms 9.6多编辑器字段,一键增加任意多编辑器》发布于石头博客文章,作者:admin,如若转载,请注明出处:https://www.pweb123.com/cms/phpcms/933.html,否则禁止转载,谢谢配合!

文章点评

我来说两句 已有0条评论
点击图片更换

添加微信好友

添加微信好友

微信小程序

百度小程序