<p>
思路,作为一个编辑器插件 FCKeidtor可以说功能非常全面,下面简单说下如何在自己的开发项目中使用这个插件
首先,下载到FCKeidtor这个软件包 点击下载
然后解压缩复制到项目根目录 并改名为比较简单的名字 editor

首先打开fckeidtor.php 发现作用是判断服务器的PHP版本,4.0就引入4.0的类,5.0就引入5.0的类
- if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) )
- include_once( 'fckeditor_php4.php' ) ;
- else
- include_once( 'fckeditor_php5.php' ) ;
然后新建一个PHP页面 new_add.php 内容如下
- <?
-
- include ("editor/fckeditor.php");
- $oBasePath = $_SERVER['PHP_SELF'];//用$_SERVER函数得到当前文件的实际路径,这里包括文件名
-
- $oBasePath = dirname ($oBasePath)."/editor/";
- $ed = new FCKeditor("con"); //实例化FCKeditor对象 给name为con
- $ed->BasePath = $oBasePath; //程序的地址为上面得到的路径
- //$ed->ToolbarSet = "Basic"; 是否使用简单模式的开关
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>无标题文档</title>
- </head>
-
- <body>
- <?
-
- if($_POST[sub])//判断$_POST[sub]是否为真,真为有内容提交
-
- {
- $con = $_POST[con];//读取FCKeditor中的内容
- $con = str_replace('\\','',$con); //替换\为空,为了让网址能正常显示
- echo "文章标题:".$_POST[title].
- "<br>文章内容".$con; //输出接收的内容
- }
-
- ?>
- <form method="post" action="">
- 文章标题<input type="text" name="title" />
- <? $ed->Create(); //创建一个FCKeditor的窗口?>
- <input type="submit" name="sub" value="提交新闻" />
- </form>
- </body>
- </html>
-
最重要的步骤是
- $oBasePath = $_SERVER['PHP_SELF'];//用$_SERVER函数得到当前文件的实际路径,这里包括文件名
-
- $oBasePath = dirname ($oBasePath)."/editor/";
- $ed = new FCKeditor("con"); //实例化FCKeditor对象 给name为con
- $ed->BasePath = $oBasePath; //程序的地址为上面得到的路径
如果要FCKeditor可以上传图片的话,要开启editor\editor\filemanager\connectors\php\config.php里面
找到 $Config['Enabled'] = false; 这是默认的
修改为 $Config['Enabled'] = true ;
找到$Config['UserFilesPath'] = '/userfiles/' ; 这是上传文件的路径改为自己的路径
如 $Config['UserFilesPath'] = '/class/userfiles/' ; 就是我的localhost/class/路径下的userfiles文件夹
</p>