【Ecshop】将内置的 FCkeditor 更换为 UEditor

1.下载UE ,解压到includes/,更名目录名为ueditor

注意更改配置后端文件上传路径,参考文档

 

2.修改admin/includes/lib_main.php,添加

 1 /**
 2  * 生成编辑器-UEditor
 3  * @param   string  input_name  输入框名称
 4  * @param   string  input_value 输入框值
 5  * @param   string  width       输入框宽度
 6  * @param   string  height      输入框高度
 7  */
 8 function create_ue_editor($input_name, $input_value = '',$width='100%',$height='320')
 9 {
10     global $smarty;
11 
12     $input_value = str_replace(["\r","'"],["\\\r","\""],$input_value);
13     
14     $ueditor='<!-- 加载编辑器的容器 -->
15     <input type="hidden" name="'.$input_name.'" id="editorcontent" value=""/>
16     <script id="'.$input_name.'" type="text/plain"></script>
17     <!-- 配置文件 -->
18     <script type="text/javascript" src="../includes/ueditor/ueditor.config.js"></script>
19     <!-- 编辑器源码文件 -->
20     <script type="text/javascript" src="../includes/ueditor/ueditor.all.min.js"></script>
21     <!-- 实例化编辑器 -->
22     <script type="text/javascript">
23         var cnt=\''.($input_value).'\';
24         //去除异常项
25         delete(Object.prototype.toJSONString);
26         var ue = UE.getEditor(\''.$input_name.'\',{
27             initialFrameWidth:\''.$width.'\',
28             initialFrameHeight:\''.$height.'\'
29         });
30         //加载完成后填入内容
31         ue.ready(function() {
32             //设置编辑器的内容
33             ue.setContent(cnt);
34         });
35         //内容更新到表单
36         ue.addListener("contentChange",function(){
37             document.getElementById("editorcontent").value=ue.getContent();
38         });
39     </script>'; 
40     $smarty->assign('UEditor', $ueditor);
41 }

3.更改后台所有获取editor的代码

create_html_editor('goods_desc', $goods['goods_desc']);
//更改为
create_ue_editor('goods_desc', $goods['goods_desc']);

4.更改后台模板所有显示editor的代码

{$FCKeditor} 
//更改为
{$UEditor}

 

posted @ 2017-08-26 23:58  GaZeon  阅读(897)  评论(0编辑  收藏  举报