Dec 27

FCKedit用法[原英文版] 不指定

bkkkd , 09:08 , 开发应用 , 评论(0) , 引用(0) , 阅读(4878) , Via 本站原创 | |

It is very easy to use FCKeditor in your PHP web pages. All the integration files are available in the official distributed package. A simple include command to the fckeditor.php file will integrate FCKeditor to your PHP pages.

Step 1

Suppose that the editor is installed in the /FCKeditor/ path of your web site. The first thing to do is to include the "PHP Integration Module" file in the top of your page, just like this:

<?php
include("FCKeditor/fckeditor.php") ;
?>

Step 2

Now the FCKeditor is available and ready to use. So, just insert the following code in your page to create an instance of the editor (usually inside a <FORM>):

<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create() ;
?>

"FCKeditor1" is the name used to post the editor data on forms.

Step 3

The editor is now ready to be used. Just open the page in your browser to see it at work.

The complete sample

<?php
include("FCKeditor/fckeditor.php") ;
?>
<html>
 <head>
   <title>FCKeditor - Sample</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 </head>
 <body>
   <form action="savedata.php" method="post">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create() ;
?>
     <br>
     <input type="submit" value="Submit">
   </form>
 </body>
</html>

Handling the posted data

The editor instance just created will behave like a normal <INPUT> field in a form. It will use the name you've used when creating it (in the above sample, "FCKeditor1").

So, to retrieve its value you can do something like this:

$sValue = stripslashes( $_POST['FCKeditor1'] ) ;

Samples

You can find some samples on how to use the editor in the "_samples/php" directory of the distributed package.

Other info

If you want to retrieve the resulting HTML instead of outputting it directly to the browser (for example if you're using it in a template engine such as Smarty), you can call the CreateHtml() method instead:

$output = $oFCKeditor->CreateHtml() ;

  • To change the size of the editor in the page, insert the following code before calling the Create() or CreateHtml() methods:

$oFCKeditor->Width  = '100%' ;
$oFCKeditor->Height = '200' ;

and just change the values to your needs.


  • To modify configuration settings in a separate file outside the editor's directory, add them to the Config property of the editor object:

$oFCKeditor->Config['CustomConfigurationsPath'] = '/myconfig.js' ;

  • To set the path for saving uploaded files uncomment the following line in /FCKeditor/editor/filemanager/browser/default/connectors/php/config.php.

// $Config['UserFilesPath'] = '/UserFiles/' ;

Note: Set the permission of the upload directory properly. You should also uncomment the settings of LinkBrowserURL and the ImageBrowserURL in the /FCKeditor_2.0fc/fckconfig.js file for the browsing and uploading function to work properly. See Built-in File Browser for more information.

Important Note for PHP with Safe Mode activated : You'll have to create /UserFiles/File, /UserFiles/Flash, /UserFiles/Image and /UserFiles/Media in order for the filebrowser to work. Of course, you'll also have to set the correct permissions for these directories. Furthermore, don't use the "Create new folder" button. The folder would be created but couldn't be used (Safe Mode restriction).

2005-12-26 18:05:07由ppp-slp-b编辑

发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]