Thinkphp the method of using Ueditor, Thinkphpueditor
The examples in this paper describe how thinkphp uses ueditor. Share to everyone for your reference, as follows:
Believe that a lot of people are still using fckeditor, I used to, but later found that Baidu Ueditor, found that ueditor better than FCKeditor, operability is also better than fckeditor, so still try to use Ueditor, However, the use of ueditor in the thinkphp framework has encountered some problems, and also took some time to solve these problems, so write a tutorial on thinkphp under the use of Ueditor, for those who need to use.
1, in the root directory of the site to build a "public" folder, this file folders in thinkphp can be replaced with __public__, so it is convenient for our program to write, and then put Ueditor files into this folder.
2, in we need to use Ueditor template file to import Ueditor to use the JS and CSS, for example, I add the following code in app/tpl/default/venter/createvent.html:
3, configuration Ueditor relative to the site root directory location, here I recommend using absolute path, that is similar to http://localhost:1080 such path, because in the development of Web site projects, many places will use Ueditor, However, because of the different location of the current directory and the server root of the relative path changes, it makes ueditor unusable, for example, I configured the path (configuration file: Ueditor directory under the Editor_config.js), the code is replaced:
Url= Tmp.substr (0,tmp.lastindexof ("\ \") +1). Replace ("_examples/", "" ");// Here you can configure the relative path to the Ueditor directory in your site or absolute path (referring to the absolute path beginning with HTTP)
Replace with:
URL = "http://localhost:1080/Public/ueditor/";
4, the following is an application of the use of forms:
As shown in the code above, you can get the contents of the Ueditor edit area by $_post[' myvent ').
5, how to use in the thinkphp? The first thing to do is to escape the resulting content submission, where we use the following code:
$content = Htmlspecialchars (stripslashes (post[' myvent '));
This is followed by inserting the $content into the database (no more speaking here).
6, extract data from the data and escape so that the content can be displayed normally:
$vent = new Ventermodel; $list = $vent->select (); $this->assign ("list", $list)
This allows you to display the content in the appropriate HTML template:
{$vo. Content|htmlspecialchars_decode}
Here is a use of the thinkphp template, that is, you can use the function in the template, where you use the function Htmlspecialchars_decode to escape the $vo,content, the above code can be seen as:
Htmlspecialchars_decode ($vo. Content), the choice of this method here I used for a long time, did not consider this method, was just thinking, because Htmlspecialchars_ The Decode function accepts a value that cannot be an array, so the data extracted from the database cannot be passed directly to him, and later it is thought that each element within the array can be htmlspecialchars_decode by iterating through the array, although the content can be escaped. But can not be displayed in the template, until the last look at some official manual, just think of here, so do the procedures, must look at the official documents, a lot of problems can be solved.
PS: Here are recommended several of the site's formatting/beautification/conversion tools can help you tidy up the messy code, I believe that you can use in future development:
PHP Code online format Beautification tool:
Http://tools.jb51.net/code/phpformat
JavaScript code beautification/compression/formatting/encryption Tools:
Http://tools.jb51.net/code/jscompress
Online XML format/compression tool:
Http://tools.jb51.net/code/xmlformat
JSON Code formatting beautification tool:
Http://tools.jb51.net/code/json
Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson
JSON code online formatting/landscaping/compression/editing/conversion tools:
Http://tools.jb51.net/code/jsoncodeformat
SQL code online Format beautification tool:
Http://tools.jb51.net/code/sqlcodeformat
More interested in thinkphp related content readers can view this site topic: "thinkphp Introductory Tutorial", "thinkphp Common Method Summary", "PHP Cookie Usage Summary", "Smarty Template Primer Basic Tutorial" and "PHP template technology Summary."
It is hoped that this article is helpful to the PHP program design based on thinkphp framework.
http://www.bkjia.com/PHPjc/1133131.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133131.html techarticle thinkphp the method of using Ueditor, Thinkphpueditor This example describes the Thinkphp method of using Ueditor. Share to everyone for your reference, as follows: I believe many people are still ...