Home  >  Article  >  Backend Development  >  ThinkPHP3.0 运用百度ueditor的正确配置方法。

ThinkPHP3.0 运用百度ueditor的正确配置方法。

WBOY
WBOYOriginal
2016-06-13 13:13:43739browse

ThinkPHP3.0 使用百度ueditor的正确配置方法。。。

使用百度ueditor,按照百度上的文章做配置,编辑器会有控件无法使用的问题,按我的方法完全能全开状态。

文件上传路径自己配置下。。。。。。

第一步:下载ueditor放到 Public 文件夹下。

?

第二步:配置 ueditor?的editor_config.js文件

?

?

URL = window.UEDITOR_HOME_URL||tmp.substr(0,tmp.lastIndexOf("\/")+1).replace("_examples/","").replace("website/","");//这里你可以配置成ueditor目录在您网站的相对路径或者绝对路径(指以http开头的绝对路径)


//改为相对路径。。。
URL = window.UEDITOR_HOME_URL||"/Public/ueditor/"; 
?


第三步:引用ueditor,在你要使用ueditor的模版文件中写入如下代码:

?

<import type='js' file="ueditor/editor_config" />
<import type='js' file="ueditor/editor_all" />
<import type='css' file="ueditor/themes/default/ueditor" />
ThinkPHP 的默认导入方式,直接就是Public目录下,不要写后缀


第四步:设置Model.class.php文件存入规则:

?

?

array('text','htmldecode', 3,'callback'),
//ThinkPHP3 正文(text)字段的自动完成规则

//文本转义
function htmldecode(){
		if(!empty($_POST['text'])){									
                        $contents=htmlspecialchars(stripslashes($_POST['text']));
			return $contents;
		}
	}
?

第五步:HTML页面应用与提取数据

?

?

<textarea type="text" name="text" id="text" style="width:100%;"/>{$list.text|htmlspecialchars_decode}</textarea>
<!--转义在这里视乎没有什么用,还是写上吧!-->

<!--script写到body外面-->
<script type="text/javascript">  
	var editor = new baidu.editor.ui.Editor();  
    editor.render("text");//这里认的是上面控件的ID
</script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn