Changing the kindeditor editor in phpweb

Source: Internet
Author: User
Tags json

All know that the built-in PHP web editor is not easy to use, and there will be many problems when submitting it! Today, we started to change the phpweb editor to the editor under the news module.

1. Download the latest kindeditor package from the official kindeditor website.
2. Delete unnecessary folders, asp, jsp, etc.
3. Put the kindeditor folder under the PHP web root directory.
4. Open news/admin/news_conadd.php at around 108 rows

The code is as follows: Copy code

<Input type = "hidden" name = "body" value = "<? Php echo $ body;?>" />
<Script type = "text/javascript" src = ".../kedit/KindEditor. js"> </script>
<Script type = "text/javascript">
Var editor = new KindEditor ("editor ");
Editor. hiddenName = "body ";
Editor. editorWidth = "680px ";
Editor. editorHeight = "300px ";
Editor. skinPath = ".../../kedit/skins/default /";
Editor. uploadPath = ".../../kedit/upload_cgi/upload. php ";
Editor. imageAttachPath = "news/pics /";
Editor. iconPath = ".../../kedit/icons /";
Editor. show ();
Function KindSubmit () {editor. data ();}
</Script>

Change

The code is as follows: Copy code

<Script charset = "UTF-8 & Prime; src =".../kindeditor. js "> </script>
<Script charset = "UTF-8 & Prime; src =".../kindeditor/lang/zh_CN.js "> </script>
<Script>
Var editor;
KindEditor. ready (function (K ){
Editor = K. create ('# editor_id ',{
Width: '680px ',
Height: '300px ',
UploadJson: 'upload _ json. Php ',
FileManagerJson: 'File _ manager_json.php ',
AllowFileManager: true,
SyncType: "form", afterCreate: function () {var self = this; self. sync () ;}, afterChange: function () {var self = this; self. sync ();}, AfterBlur: function () {var self = this; self. sync () ;}}) ;}</script>
<Textarea name = "body" id = "editor_id" style = "width: 680px; height: 300px;"/> <? Php echo $ body;?> </Textarea>

Note: According to the official demo. Php file, the content in textarea cannot be obtained in the red mark! 5. Copy the upload_json.php and file_manager_json.php files under the kindeditorphp folder (JSON. php is also copied in the new version) to newsadmin to modify the two files.

// File Save directory path $ save_path = $ php_path. '../attached/'; // File Save Directory URL $ save_url = $ php_url. '../attached /';
Is

// File Save directory path $ save_path = $ php_path. '../pics/'; // File Save Directory URL $ save_url = $ php_url. '../pics /';

Problems encountered

When kindeditor is submitted using ajax, the following problem occurs: the second submission can obtain the actual value. Solve the problem as follows:

Add one. afterChange: function (e) {this. sync ()} to synchronize the data.

Replace it with OK:

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.