日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ECShop替换FCKeditor编辑器为KindEditor

發布時間:2025/4/16 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ECShop替换FCKeditor编辑器为KindEditor 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么80%的碼農都做不了架構師?>>> ??

理論上可以替換包括百度ueditor在內的其他任何編輯器,步驟包括:

1.上傳新編輯器代碼

首先下載Kindeditor,解壓后將文件夾命名為kindeditor,刪除包內的無用文件,如asp*、jsp、examples、attached等,保留*-min.js

然后進入kindeditor/php/,修改file_manager_json.php文件:

$root_path = $php_path . '../../../images/upload/'; $root_url = $php_url . '../../../images/upload/';

再修改upload_json.php第16行:

$save_path = $php_path . '../../../images/upload/'; $save_url = $php_url . '../../../images/upload/';

最后將整個kindeditor文件夾上傳至/ecshop/include/目錄.


2.刪除FckEditor引用及原始文件

接下來進入/admin/目錄,刪掉所有fckeditor的引用,找到以下文件:

article.phpfilecheck.phpmagazine_list.phpgoods.phpshophelp.phpshopinfo.phpsuppliers_goods.phptopic.php

在上述文件中查找下面其中一行并刪除掉:

require_once(ROOT_PATH."includes/fckeditor/fckeditor.php"); include_once(ROOT_PATH.'includes/fckeditor/fckeditor.php');

然后可以刪除掉整個fckeditor文件夾,即/includes/fckeditor/


3.修改編輯器兼容性功能及樣式

  • 首先找到/admin/includes/lib_main.php,將整個create_html_editor函數重寫(第311行):
/*** 生成編輯器* @param string input_name 輸入框名稱* @param string input_value 輸入框值* @param string params 額外參數*/ function create_html_editor($input_name, $input_value = '', $params = '') {global $smarty;$kindeditor="<script charset=\"utf-8\" src=\"../includes/kindeditor/kindeditor-min.js\"></script><script charset=\"utf-8\" src=\"../includes/kindeditor/plugins/autoheight/autoheight.js\"></script><script type=\"text/javascript\">var editor;function initEditor() {KindEditor.ready(function(K) {editor = K.create('textarea[name=\"$input_name\"]', {allowFileManager : true,autoHeightMode: true$params});});}initEditor();</script><textarea id=\"$input_name\" name=\"$input_name\" style=\"width:100%\">$input_value</textarea>";$smarty->assign('FCKeditor', $kindeditor); }

lib_main.php是后臺的基本類庫,很多功能都會自導加載這個文件,而上面這個函數將會以下其他地方引用到。


  • 然后打開/admin/order.php第2469行,從include_once..到“$smarty->assign('fckeditor', $fckeditor)

該功能用于訂單打印模板修改,如果沒找到以上代碼,直接搜索fckeditor即可。將該段內容刪除后再插入以下代碼:

create_html_editor('FCKeditor1', $file_content, ",fullscreenMode:true,width:'100%'");

(注意這里我加了參數使頁面打開時編輯器自動全屏。)


  • 再修改/admin/mail_template.php,將第27行“include_once..fckeditor.php..”刪除,

然后將第65行創建html editor的部分(同上面訂單打印)替換為:

create_html_editor('content', $content['template_content']);

在這塊代碼下面第83行找到“載入指定模版”將elif中的全部內容刪除并替換為以下代碼:

elseif ($_REQUEST['act'] == 'loat_template') {$tpl = intval($_GET['tpl']);$content = load_template($tpl);make_json_result($content); }

這里是用于加載郵件模板的JSON請求,但是ecshop寫的實在太蹩腳了簡直無法直視…關鍵是不兼容kindeditor,只好做了修改。


  • 以上內容改完后,還需要修改部分htm模板,首先是訂單模板頁order_templates.htm

將“{$fckeditor}”改為“{$FCKeditor}”即可,原因是公共函數中變量名改變了。然后是goods_info.htm

將第429行的button改為submit,否則商品詳情可能無法保存。

最后是郵件模板頁mail_template.htm將整個文件替換為如下代碼

{if $full_page} {include file="pageheader.htm"} {insert_scripts files="../js/utils.js,listtable.js"} <div class="form-div" id="conent_area"> {/if} <form method="post" name="theForm" action="mail_template.php?act=save_template"><table id="general-table"><tr><td style="font-weight:bold" width="15%">{$lang.select_template}</td><td><select id="selTemplate" name="tpl" onchange="loadTemplate()" style="width:304px">{html_options options=$templates selected=$cur}</select></td></tr><tr><td style="font-weight: bold; " width="15%">{$lang.mail_subject}:</td><td><input type="text" name="subject" id="subject" style="width:300px" value="{$template.template_subject}"/></td></tr><tr><td colspan="2">{$FCKeditor}</td></tr><tr><td colspan="2" align="center"><input type="hidden" name="is_html" value="1" /><input type="submit" value="{$lang.button_submit}" class="button" /></td></tr></table> </form> {if $full_page} </div> <script language="JavaScript"> {literal} var orgContent = ''; /* 定義頁面狀態變量 */ onload = function() {document.getElementById('selTemplate').focus();document.forms['theForm'].reset();// 開始檢查訂單startCheckOrder(); }/*** 載入模板*/ function loadTemplate() {curContent = document.getElementById('content').value;if (orgContent != curContent && orgContent != '' && !confirm(save_confirm))return;var tpl = document.getElementById('selTemplate').value;Ajax.call('mail_template.php?is_ajax=1&act=loat_template', 'tpl=' + tpl, loadTemplateResponse, 'GET', 'JSON'); }/*** 將模板的內容載入到文本框中*/ function loadTemplateResponse(result, textResult) {if (result.error == 0) {editor.html(result.content.template_content); document.getElementById('subject').value = result.content.template_subject;orgContent = '';}if (result.message.length > 0)alert(result.message); } {/literal} </script> {include file="pagefooter.htm"} {/if}


P.S.

后臺無法讀取cookie,原因是/ecshop/admin/templates/menu.htm中第380行調用了一個不存在的函數t_eval(),

其實這個函數在/ecshop/admin/js/menu.js中定義了只是從未引用而已,將其修改為以下代碼:

this.SourceObject = eval("("+ document.getCookie(this.CookieName) +")");


轉載于:https://my.oschina.net/cwalet/blog/333314

總結

以上是生活随笔為你收集整理的ECShop替换FCKeditor编辑器为KindEditor的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。