首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 網頁程式設計 >> PHP 程式設計 >> PHP 相關知識

ECShop 後台編輯器替換為 UEditor 1.4.3 完整教程(含 jQuery 衝突修復)

     編輯:PHP 相關知識

ECShop 默認使用 FCKeditor,體驗較差。本文記錄將後台編輯器完整替換為百度 UEditor 1.4.3 的全過程,包含文件部署、核心代碼修改、jQuery 衝突解決、商品編輯頁 Bug 修復,操作可直接落地。

準備工作

  1. 下載 UEditor 1.4.3:官網下載(截至 2015-03-03 最新版)。
  2. 下載 jQuery 衝突修復包:含修復後的 jQuery 相關文件及已調整 php/config.json 圖片保存路徑的配置。百度網盤 密碼:fflu。解壓後忽略 .DS_Store 文件。

文件部署

# 1. 將 ueditor 目錄上傳至網站根目錄 /includes/
# 2. 將修復包 fix_jquery 目錄上傳至 /includes/ueditor/

核心代碼修改

1. 修改 /admin/includes/lib_main.php 重寫編輯器生成函數

找到 create_html_editor 函數,替換為:

function create_html_editor($input_name, $input_value = '') {
    global $smarty;
    $kindeditor = "<script id='editor' name='$input_name' type='text/plain' style='width:1024px;height:500px;'>$input_value</script>
<script charset='utf-8' src='../includes/ueditor/ueditor.config.js'></script>
<script charset='utf-8' src='../includes/ueditor/ueditor.all.min.js'></script>
<script>
var ue = UE.getEditor('editor');
</script>";
    $smarty->assign('FCKeditor', $kindeditor);
}

2. 修改 /admin/templates/pageheader.htm 引入修復後的 jQuery

查找 {insert_scripts files="../js/transport.js,common.js,../js/utils.js"},替換為:

<script src="../includes/ueditor/fix_jquery/jquery.min.js"></script>
<script src="../includes/ueditor/fix_jquery/jquery.json-1.3.js"></script>
<script src="js/common.js"></script>
<script src="../includes/ueditor/fix_jquery/transport_json.js"></script>
{insert_scripts files="../js/utils.js"}

3. 修復商品編輯頁編輯器內容丟失 Bug

文件:/admin/templates/goods_info.htm
找到 document.forms['theForm'].reset(); 並註釋掉:

// document.forms['theForm'].reset();

原因:表單重置會清空 UEditor 的隱藏 textarea,導致內容無法提交。

驗證與後續

  • 進入後台商品編輯、文章發布頁面,確認 UEditor 正常加載、圖片上傳、內容提交無誤。
  • 如需調整上傳路徑,編輯 /includes/ueditor/php/config.json 中的 imagePath 等字段。
  • 若網站已使用其他 jQuery 插件,請確保 fix_jquery 中版本兼容,必要時手動調整 jQuery.noConflict()。

完成上述步驟,ECShop 後台即擁有現代化、功能豐富的 UEditor 編輯體驗。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved