思路,做为一个编辑器插件 FCKeidtor能够说功能很是全面,下面简单说下如何在本身的开发项目中使用这个插件php
首先,下载到FCKeidtor这个软件包 点击下载html
而后解压缩复制到项目根目录 并更名为比较简单的名字 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 内容以下ide
- <?
- /*用include方法加载类的文件,这个文件会自动判断服务器的PHP版本,4.0自动调用4.0的类,5.0调用5.0的类*/
- include ("editor/fckeditor.php");
- $oBasePath = $_SERVER['PHP_SELF'];//用$_SERVER函数获得当前文件的实际路径,这里包括文件名
- /*用dirname函数获得去掉文件名的路径加上/editor/获得FCKeditor的路径*/
- $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>
最重要的步骤是 函数
若是要FCKeditor能够上传图片的话,要开启editor\editor\filemanager\connectors\php\config.php里面post
找到 $Config['Enabled'] = false; 这是默认的ui
修改成 $Config['Enabled'] = true ;spa
找到$Config['UserFilesPath'] = '/userfiles/' ; 这是上传文件的路径改成本身的路径插件
如 $Config['UserFilesPath'] = '/class/userfiles/' ; 就是个人localhost/class/路径下的userfiles文件夹