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: