I will use xheditor as the new online editor. I hope it can be called through a PHP function, as shown in
CopyCodeThe Code is as follows: function Editor ($ content, $ name)
{
$ Editor = <EOT
<Textarea id = "$ name" name = "$ name" rows = "10" Cols = "60"> $ content </textarea>
EOT;
Return $ editor;
}
The benefits of doing so are:
1. You do not need to call the xheditor every time.
2. Easy to call. You can put the returned HTML code variables on the template.
I used the get () method in jquery to asynchronously code xheditor, and then run the Code with eval.
As follows:Copy codeThe Code is as follows:
Function Editor ($ content, $ name)
{
$ Editor = <EOT
$ (Document). Ready (
Function (){
If (! $. Isfunction ($. xheditor ))
{
$. Get (
'../Xheditor. js ',
Function (data ){
Eval (data );
}
);
}
$ ('# {$ Name}'). xheditor (true );
}
);
<Textarea id = "$ name" name = "$ name" rows = "10" Cols = "60"> $ content </textarea>
EOT;
Return $ editor;
}
If the above Code is correct, you cannot run it.
Because the 0.9.8 version of xheditor may encounter problems during asynchronous loading. As a result, xheditor cannot be properly displayed.
Cause:
Jsurl is obtained by obtaining the page. However, I use asynchronous loading, so I need to specify the jsurl address.
Patch:
Open xheditor. js and find the following code:Copy codeThe Code is as follows: var defaults = {skin: "default", tools: "full", internalscript: false, inlinescript: false, internalstyle: false, inlinestyle: True, showblocktag: false, forceptag: True, keepvalue: True, uplinkext: "Zip, rar, TXT", upimgext: "JPG, JPEG, GIF, PNG", upflashext: "SWF", upmediaext: "Avi", modalwidth: 350, modalheight: 220, modaltitle: true };
ChangeCopy codeThe Code is as follows: var defaults = {skin: "default", tools: "full", internalscript: false, inlinescript: false, internalstyle: false, inlinestyle: True, showblocktag: false, forceptag: True, keepvalue: True, uplinkext: "Zip, rar, TXT", upimgext: "JPG, JPEG, GIF, PNG", upflashext: "SWF", upmediaext: "Avi", modalwidth: 350, modalheight: 220, modaltitle: True, editorurl: NULL };
In fact, the default value of editorurl is added.
Then findCopy codeThe Code is as follows: This. settings = $. Extend ({}, defaults, options );
AddCopy codeThe Code is as follows: jsurl = This. settings. editorurl | jsurl;
Used to set whether jsurl uses the default value or a user-defined directory
A parameter will be added when xheditor is called later.Copy codeThe Code is as follows: editorurl
The URL path of the editor. The path must contain "/". The default value is null.
Open the root directory load_xheditor.html in the browser.
File Packaging