Thinkphp 2.0 Consolidated FCK Editor

Source: Internet
Author: User

First of all, now the latest version of the FCK package, extracted to tp the third Party Library folder: Vendor

Start configuration FCK:

First, find the FCK root directory fckeditor_php5.php, about 130 lines of __construct, modify FCK path information: $this->basepath = '/thinkphp/vendor/fckeditor/' ;

Second, set editor picture upload directory, find fck:fckeditor/editor/filemanager/connectors/php, about 34 lines set: $Config [' userfilespath '] = ' thinkphp/ Uploadfiles/'; Remember, to create this folder in the root directory, ensure that the user has write permission.

Start calling the FCK editor in the TP template:

For example, in the controller index call, then the controller in the wording:
The Public Function index () {Vendor ("fckeditor.fckeditor");//contains the FCKeditor class library, TP introduces the system method of the third party class library, its path is relative to the vendor directory. $editor = new FCKeditor (); Instantiate the FCKeditor object $editor->width= ' 980 ';//Set the width that the editor actually needs. If this item is omitted, the default width is used. $editor->height= ' 400 ';//Set the height that the editor actually needs. If this is omitted, the default height is used. $this->value= ';//Set editor initial value. It can also be a set value when modifying data. can be empty. $editor->instancename= ' comment '; Enter the ID and name of the tag in the form that contains the label, that is, the ID and name of the <input> label. Here is the false//Set as comment. This is not a province, but also to maintain uniqueness. Once the form is uploaded to the server handler, it can be read by $_post[' comment '. $html = $editor->createhtml ()//creates an online editor HTML code string and assigns value to the string variable $html. $this->assign (' HTML ', $html);//assigns $html values to the template variable $html. You can refer directly to the template through {$html}. D (); $this->display (); }
In the TP Template:
Where you need to invoke the editor: {$html}

Here's an example:

Vendor ("Fckeditor.fckeditor"); $editor = new FCKeditor (' Content '); Instantiate the FCKeditor object $editor->width= ' 98% '; $editor->height= ' 400 '; $this->value= '; $html = $editor->createhtml (); $this->assign (' HTML ', $html);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.