Jacky's Blog Jacky's Blog
  • 首页
  • 关于
  • 项目
  • 大事记
  • 留言板
  • 友情链接
  • 分类
    • 干货
    • 随笔
    • 项目
    • 公告
    • 纪念
    • 尝鲜
    • 算法
    • 深度学习
首页 › 干货 › 替换 ECShop 3.0 编辑器为 Kindeditor

替换 ECShop 3.0 编辑器为 Kindeditor

Jacky
10月 1, 2016干货阅读 2,509

前言

博主最近在折腾一个公司的商城项目,用的是 ECShop 3.0,然而到了2016年,这个曾经风靡一时的开源程序居然还在用着 N 年不更新的编辑器(Fckeeditor)界面丑的一比也不多说了,功能也是不能满足日常需求。

于是看了看网上的资料和 Kindeditor 的官方文档,决定将 ECShop 3.0 的编辑器换成 Kindeditor,本方案可在 ECShop 2.x 使用~

替换过程

1.从 Kindeditor 的 Github 开源页面下载最新版本 https://github.com/kindsoft/kindeditor

替换 ECShop 3.0 编辑器为 Kindeditor-Jacky's Blog

切记要从 Clone or download 中 Download ZIP,因为最新 Release 版本有 BUG!下载解压后,可以将不需要的程序版本删除,只留下 php 就可以了,当然不删除也没有什么问题 :)
然后将文件夹改名为 kindeditor 并上传至 includes/ 下。

2.修改 admin/includes/lib_main.php
先搜索 create_html_editor,将这个 function 注释掉,然后在这个文件的底部添加如下代码

function create_html_editor ($input_name, $input_value = '')
{
    global $smarty;
    $kindeditor="<script charset='utf-8' src='../includes/kindeditor/kindeditor-all-min.js'></script>
     <script>
        var editor;
           KindEditor.ready(function(K) {
                editor = K.create('textarea[name=\"$input_name\"]', {
                   allowFileManager : true,
                   width : '111%',
                   height: '400px',
                   newlineTag: 'br',
                   //resizeType: 0 //固定宽高
                 });
             });
     </script>
     <textarea id=\"$input_name\" name=\"$input_name\" style='width:700px;height:300px;'>$input_value</textarea>
 ";

     $smarty->assign('FCKeditor', $kindeditor);
}

3.修改 Kindeditor 的图片上传目录
修改 includes/kindeditor/php/upload_json.php

将 $save_path 和 $save_url 改为 ECShop 的附件目录与URL

//文件保存目录路径
 $save_path = $php_path . '../../../images/upload/';
 //文件保存目录URL
 $save_url = $php_url . '../../../images/upload/';

并找到$ymd = date("Ymd");改为:$ymd = date("Ym");这样附件目录的就会按照 ECShop 默认的以年月来划分文件夹~

4. 修改浏览服务器路径
修改 includes/kindeditor/php/file_manager_json.php
找到 $root_path $root_url 将目录改为

//根目录路径,可以指定绝对路径,比如 /var/www/attached/
$root_path = $php_path . '../../../images/upload/';
//根目录URL,可以指定绝对路径,比如 http://www.yoursite.com/attached/
$root_url = $php_url . '../../../images/upload/';

5.注释掉 goods.php 和 article.php 中调用 Fckeditor 的代码
在 admin/goods.php admin/article.php 中搜索 include_once(ROOT_PATH . 'includes/fckeditor/fckeditor.php');并将它们注释掉。

6.提交同步
修改 admin\templates\goods_info.htm 搜索 document.forms['theForm'].submit(); 在这行代码上方添加 editor.sync();//同步编辑框的文字;

那么到这里,ECShop 3.0 更换商品编辑器就完成了,最后的效果如下图~

替换 ECShop 3.0 编辑器为 Kindeditor-Jacky's Blog

最后附上 Kindeditor 的官方文档:http://kindeditor.net/doc.php

赞(1)
macOS Sierra 允许任何来源的应用
上一篇
MSettings 深度系统定制 For iOS
下一篇
再想想
所有评论(1)
  • Jacky

    kindeditor 貌似也很久没更新了,改天有空换成 ckeditor 😡

    6年前 回复
近期评论
  • Jacky发表在《Nginx UI》
  • daiwenzh5发表在《Nginx UI》
  • Jacky发表在《Nginx UI》
  • daiwenzh5发表在《Nginx UI》
  • Jacky发表在《Nginx UI》
1 1
  • 1
  • 1
Copyright © 2016-2023 Jacky's Blog. Designed by nicetheme.
粤ICP备16016168号-1
  • 首页
  • 关于
  • 项目
  • 大事记
  • 留言板
  • 友情链接
  • 分类
    • 干货
    • 随笔
    • 项目
    • 公告
    • 纪念
    • 尝鲜
    • 算法
    • 深度学习
# Mac # # Apple # # OS X # # iOS # # macOS #
Jacky
PHP C C++ Python | 舞象之年 | 物联网工程
174
文章
169
评论
267
喜欢