新聞中心
怎么講phpcms v9網(wǎng)站程序中整合添加百度編輯器UEditor
眾所周知,大部分開源程序后臺(tái)都會(huì)自帶編輯器,但是很多人會(huì)抱怨后臺(tái)自帶的編輯器功能不夠強(qiáng)大,或者使用不是很方便,今天無(wú)憂主機(jī)小編再次寫一篇關(guān)于百度編輯器的教程,就是把phpcms的默認(rèn)編輯器替換成百度編輯器。
具體方法如下
1、先到官網(wǎng)下載資源包(先定制編輯器導(dǎo)航工具,自定義添加需要的功能再下載)
[caption id="attachment_14305" align="alignnone" width="549"] 百度編輯器[/caption]
2、上傳到phpcms默認(rèn)的js文件路徑,上傳后的文件路徑如下
\statics\js\ueditor\
3、打開/phpcms/libs/classes/form.class.php,找到如下代碼:
if(!defined('EDITOR_INIT')) {
$str = '<script type="text/javascript" src="'.JS_PATH.'ckeditor/ckeditor.js"></script>';
define('EDITOR_INIT', 1);
}
替換成:
if(!defined('EDITOR_INIT')) {
$str = '<script type="text/javascript" src="'.JS_PATH.'ueditor/editor_config.js"></script>';
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/editor_all.js"></script>';
$str .= '<link rel="stylesheet" href="'.JS_PATH.'ueditor/themes/default/ueditor.css"/>';
define('EDITOR_INIT', 1);
}
$str .= "<script type=\"text/javascript\">\r\n";
$str .= "var editor = new baidu.editor.ui.Editor();editor.render('$textareaid');";
$str .= '</script>';
[caption id="attachment_14306" align="alignnone" width="552"]
代碼[/caption]
修改后效果
4、打開/statics/js/ueditor/editor_config.js,找到如下代碼:
var URL;
/**
* 此處配置寫法適用于UEditor小組成員開發(fā)使用,外部部署用戶請(qǐng)按照上述說(shuō)明方式配置即可,建議保留下面兩行,以兼容可在具體每個(gè)頁(yè)面配置window.UEDITOR_HOME_URL的功能。
*/
var tmp = location.protocol.indexOf("file")==-1 ? location.pathname : location.href;
URL = window.UEDITOR_HOME_URL||tmp.substr(0,tmp.lastIndexOf("\/")+1).replace("_examples/","").replace("website/","");//這里你可以配置成ueditor目錄在您網(wǎng)站的相對(duì)路徑或者絕對(duì)路徑(指以http開頭的絕對(duì)路徑)
替換成:
var URL;
var tmp = window.location.pathname,
URL= "/statics/js/ueditor/"
/**
* 此處配置寫法適用于UEditor小組成員開發(fā)使用,外部部署用戶請(qǐng)按照上述說(shuō)明方式配置即可,建議保留下面兩行,以兼容可在具體每個(gè)頁(yè)面配置window.UEDITOR_HOME_URL的功能。
*/
/ar tmp = location.protocol.indexOf("file")==-1 ? location.pathname : location.href;
//URL = window.UEDITOR_HOME_URL||tmp.substr(0,tmp.lastIndexOf("\/")+1).replace("_examples/","").replace("website/","");//這里你可以配置成ueditor目錄在您網(wǎng)站的相對(duì)路徑或者絕對(duì)路徑(指以http開頭的絕對(duì)路徑)
就是把默認(rèn)的“var tmp”和“URL”注釋掉,換成百度編輯器的地址;
5、修改編輯器默認(rèn)寬度和高度,因?yàn)閜hpcms默認(rèn)編輯器沒有那么大:
在/statics/js/ueditor/editor_config.js找到112、113行,
//,initialFrameWidth:1000 //初始化編輯器寬度,默認(rèn)1000
//,initialFrameHeight:320 //初始化編輯器高度,默認(rèn)320
替換成:
,initialFrameWidth:655 //初始化編輯器寬度,默認(rèn)1000
,initialFrameHeight:400 //初始化編輯器高度,默認(rèn)320
如此,在添加文章時(shí),編輯器就不會(huì)變形。
本文地址:http://www.love62.cn/phpcms/14304.html
![1](/wp-content/themes/starow_z/img/o-1.png)
![1](/wp-content/themes/starow_z/img/o-2.png)
![1](/wp-content/themes/starow_z/img/o-3.png)
![1](/wp-content/themes/starow_z/img/o-4.png)
![1](/wp-content/themes/starow_z/img/o-5.png)
![1](/wp-content/themes/starow_z/img/o-6.png)
![1](/wp-content/themes/starow_z/img/o-7.png)