Php application of FCKeditor

Source: Internet
Author: User
Tags blank page

FCKeditor is a powerful webpage text editor that supports multiple scripting languages and languages.

Official Website http://www.FCKeditor.net/

Here is the PHP configuration method. The configuration method in other languages is the same as it.

Assume that the website directory is:
/WWW
/Index. php
/INC
/FCKeditor
I. Two methods to call FCKeditor
1: Create an instance
Here, we only write the code to call it. Of course, you write other code for the website, and add the following code to the desired place.

Code:
<? Php
Include_once ("FCKeditor/fckeditor. php"); // reference the FCKeditor. php file.
$ FCKeditor = new FCKeditor ("myinfo"); // create an instance of the FCKeditor object
$ FCKeditor-> BasePath = "FCKeditor/"; // the location where FCKeditor is located. The location here is "FCKeditor /";
$ FCkeditor-> ToolbarSet = "Default"; // tool button settings
$ FCKeditor-> Width = "100%"; // set its Width.
$ FCKeditor-> Height = "300px"; // set its Height.
$ FCkeditor-& gt; Cr & #101; ate ();
?>

2: create by calling iframe
Add

Code:
<INPUT id = content style = "DISPLAY: none" type = hidden name = "myinfo">
<INPUT id = content ___ Config style = "DISPLAY: none" type = hidden>
<IFRAME id = content ___ Frame src = "FCKeditor/editor/fckeditor.html? InstanceName = myinfo & amp; Toolbar = Default "frameBorder = 0 width = 100% scrolling = no height = 300>
</IFRAME>

Description of the above two methods:

In the above two methods, you can see the string "myinfo". You may not know what it means. Now I will explain it to you.
You can use
$ _ Post ["myinfo"] or use $ _ Get ["myinfo"] to obtain the content in the text editor, whether to use post or get depends on what method you are using.

Of course, you can also change myinfo to what you want, such as "content ".

If you do not know what Ajax is, you do not need to read this passage.
When you use ajax to obtain the content, do you find that the content is not available? For example:
<SCRIPT> alert (document. Form. content. Value) </SCRIPT>
Then we can get its content through the following code:
Function getContentValue ()
{
Var oEditor = FCKeditorAPI. GetInstance ("content ");
Var acontent = oEditor. GetXHTML ();
Return acontent;
}

Ii. Configure some files
1: fckconfig. js Configuration
(1). Tool button settings

Find FCKConfig. ToolbarSets ["Default"]. There are many buttons, and we will introduce them in detail below.

EditSource: HTML source code StrikeThrough
Save Subscript
NewPage create blank page Superscript
Preview JustifyLeft left
Cut JustifyCenter Center Align
Copy JustifyRight right
Paste JustifyFull on both ends for alignment
PasteText plain text paste Ins & #101; rtOrderedList automatic number
PasteWord pasted Ins from Word & #101; rtUnorderedList project symbol
Print Outdent reduce indent
Added Indent for SpellCheck spelling check
Find ShowTableBorders show Table Line
Replace ShowDetails display details
Undo Form addition action
Redo restore Checkbox check box
Sel & #101; ctAll select Radio button
RemoveFormat removes the format Input single-line text box
Link insert/edit Link Textarea scroll text box
RemoveLink remove connecting Sel & #101; ct drop-down menu
Anchor Button
Image insert/edit ImageButton Image button
Table insert/edit Table Hidden hide
Rule insert horizontal line Zoom display Ratio
SpecialChar Insert special character FontStyleAdv system font
Universalkey soft keyboard fontstyle Font Style
Smiley insert emoticon fontformat
About font
Bold bold fontsize
Italic italic textcolor text color
Underline underline bgcolor background color

By default, all tool buttons are included. However, some buttons are not required when we use them, and the speed is also affected. We can delete unnecessary buttons. The following is my configuration for your reference. Of course you can follow your preferences.
Fckconfig. toolbarsets ["default"] = [
["Editsource", "save", "Newpage", "preview", "-", "cut", "copy", "Paste", "pastetext ", "-", "find", "replace", "-", "undo", "redo", "-", "sel & #101; ctall ", "-", "Link", "removelink", "-", "image", "table", "rule", "specialchar", "smiley"],
["Bold", "italic", "underline", "-", "justifyleft", "justifycenter", "justifyright", "-", "ins & #101; rtorderedlist "," ins & #101; rtunorderedlist ","-"," form "," checkbox "," radio "," input "," textarea ", "sel & #101; CT", "button", "-", "fontstyleadv", "textcolor"];

If you reply a post to the user at the front-end, there is no need to post it. You can add one at this time:
FCKConfig. ToolbarSets ["Basic"] = [
["Bold", "Italic", "-", "OrderedList", "UnorderedList", "-", "Link", "Unlink ","-", "About"]
];

In this case, you need to use $ FCKeditor-> ToolbarSet = "Basic" when calling at the front-end. It cannot be "Default.

(2): Language Configuration

Find FCKConfig. DefaultLanguage and set it to "zh-cn ".

(3): script language settings

Find var _ FileBrowserLanguage and var _ QuickUploadLanguage and set them to "php". The default value is "asp". If this parameter is not set, Images cannot be uploaded. This is very important. At that time, I was using FCKeditor because I didn't configure this file, so I couldn't upload images, but I used asp to upload images in my dormitory, which bothered me for many days and finally found the reason.

2: Image Upload Configuration

Open the file FCKeditor/editor/filemanager/browser/default/connectors/php/config. php
Find $ Config ["Enabled"] and set it to "true"
Search for $ Config ["UserFilesPath"] and set the image Directory, which is relative to the main directory // For example: I wrote a blog, you can set it to/blog/upload/

Open the file FCKeditor/editor/filemanager/upload/php/config. php
Find $ Config ["Enabled"] and set it to "true"
Find $ Config ["UseFileType"] and set the directory of the uploaded file. It is better to be the same as the image directory above.

Now all the configurations have been completed. All you have to do is delete unnecessary files.
All directory names and file names that contain "_" can be deleted. Of course, you use php and some directories in other languages can also be deleted. This reduces the file size.

 

Address: http://hi.baidu.com/s_jqzhang/blog/item/5b507a2c0f5997e48b139976.html

Personal notes:

1. For some tools, 2.6.4 may differ from previous tools in terms of naming.

2. Choose your tools options.

<Iframe id = "body ___ Frame" src = "../include/FCKeditor/editor/fckeditor.html? InstanceName = body & amp; toolbar = Basic "width =" 100% "height =" 450 "frameborder =" no "scrolling =" no "> </iframe> note that, generally, the default is selected. haha

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.