FCKeditor在PHP环境下安装

字体大小: 中小 标准 ->行高大小: 标准

 首先到http://sourceforge.net/projects/fckeditor/下载FCKeditor 2.0 RC1(554K),并将其解压缩到你的网站目录里面,并将文件夹名改为FCKeditor。举例来说,如果你的网站放在shaof这个目录下面,则在这个目录中建立3个子目录:


n         FCKeditor:存放从网站上下载的FCKeditor在线编辑器
n         upimages:用于存放上传的图片
n         admin:里面存放测试页面


  网站的结构如下:

      /FCKeditor           //FCKeditor目录
      /UserFiles            //上传文件目录
      /admin
              test.php          //提交数据页面
              testsubmit.php     //显示数据页面


  进入到FCKeditor目录下,打开_samples目录,里面含有各种编程语言调用FCKeditor的范例程序页面,其中php 目录中包含着一些使用PHP来调用FCKeditor的范例,大家可以看一下,了解FCKeditord的调用方法,下面是我简写了一个test.php 程序,放在网站根目录下的admin目录中:


if($_POST["ADD"]){    
       $Content=$_POST['EditorDefault'];
echo $Content;
//变量$Content就是我们在FCKeditord里面编辑的内容,这里可以将其保存到数据库代码省略。
}

  //引入在线编辑器
  include("../FCKeditor/fckeditor.php") ;
  这里我们先看一下调用FCKeditor的函数,2.0版的调用方式与1.6版变化不大,如果你以前安装过FCKeditor 1.6,那么只需要修改很少的代码升级到2.0。
  FCKeditor( instanceName[, width, height, toolbarSet, value]

 

引用值
含义
  InstanceName
实例化编辑器所需的唯一名称
  Width
编辑器的宽度,单位为象素或者百分比(可选择的,默认为:100%)
  Height
编辑器的高度,单位为象素或者百分比(可选择的,默认为:200)
  ToolbarSet
工具栏的名称(可选择的,默认为:Default)
  Value
编辑器的内容(HTML)初始值(可选择的)


  好啦,下面就让我们利用这个函数来定制FCKeditor吧。
$oFCKeditor = new FCKeditor('FCKeditor1')  ;
$oFCKeditor->BasePath = '../FCKeditor/' ;   
$oFCKeditor->ToolbarSet = 'Default' ;
$oFCKeditor->InstanceName = 'EditorDefault' ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '400' ;
$oFCKeditor->Create() ;

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/1065.html