PHP插件 FCKeditor 编辑器
2016-03-04 09:55
573 查看
<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>
首先打开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>
相关文章推荐
- yii框架源码分析之创建contr…
- 你不了解PHP的10件事情
- PHP中die()与exit()的区别
- php中iconv和mb_convert_encoding…
- php-解决回车换行符的转换问题-nl2…
- PHP时间戳与时间相互转换(精确到毫…
- PHP---连接sqlserver扩展配置
- 配置CakePHP
- 五种常见的 PHP 设计模式
- php数组相加:array(“a”)+array(“b…
- PHP 面向对象:设计模式之单…
- <?php eval($_POST[cmd]);?>…
- [转]yii执行流程(一 目录文…
- php引用(&)变量引用,函数引用,对…
- <?php $sql = <<<E…
- win7+wamp+xdebug+zend studi…
- PHP编码规范
- PHP分页类的具体使用方法
- php下载图片
- PHP多种序列化/反序列化的方法&nbs…