没有合适的资源?快使用搜索试试~ 我知道了~
首页FCKeditor使用方法技术详解.pdf
资源详情
资源评论
资源推荐

FCKeditor 使用方法技术详解
1、 概述
FCKeditor 是目前最优秀的可见即可得网页编辑器之一,它采用 JavaScript 编写。具备
功能强大、配置容易、跨浏览器、支持多种编程语言、开源等特点。它非常流行,互联网上
很容易找到相关技术文档,国内许多 WEB 项目和大型网站均采用了 FCKeditor(如百度,
阿里巴巴)。本文将通过与 PHP 相结合,从基本安装到高级的配置循序渐进介绍给广大
PHPer。
FCKeditor 官方网站:http://www.fckeditor.net/
FCKeditor Wiki:http://wiki.fckeditor.net/
2、 下载 FCKeditor
登录 FCKeditor 官方站(http://www.fckeditor.net),点击网站右上角“Download”链接。
笔者编写本文时,FCKeditor 当前最新的稳定版本是 2.4.3,因此我们下载此版本的 zip 压缩
格式文档。如图 1 所示:
图 1:下载 FCKeditor 2.4.3(最新稳定版)
注意:当点击“FCKeditor_2.4.3.zip”链接后,将跳转到 sourceforge.net 网站上自动下载。如
果您当前使用 Linux 或 Unix 系统,可以点击“FCKeditor_2.4.3.tar.gz”链接下载.tar.gz 格式
的压缩包。

3、 安装 FCKeditor
解压“FCKeditor_2.4.3.zip”文档到您的网站目录下,我们先假定您存放 FCKeditor 和调
用脚本存于同一个目录下。目录结构如下图所示:
图 2:网站目录结构图
fckeditor 目录包含 FCKeditor2.4.3 程序文件。check.php 用于处理表单数据。add_article.php
和 add_article_js.html 分别是 PHP 调用 FCKeditor 和 JavaScript 调用 FCKeditor 实例脚本文件。
3.1、用 PHP 调用 FCKeditor
调用 FCKeditor 必须先载入 FCKeditor 类文件。具体代码如下。
<?php
include("fckeditor/fckeditor.php") ; // 用于载入 FCKeditor 类文件
?>
接下来,我们需要创建 FCKeditor 实例、指定 FCKeditor 存放路径和创建(显示)编辑器等。
具体代码如下所示(代码一般放在表单内)。
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ; // 创建 FCKeditor 实例
$oFCKeditor->BasePath = './fckeditor/'; // 设置 FCKeditor 目录地址
$FCKeditor->Width='100%'; //设置显示宽度
$FCKeditor->Height='300px'; //设置显示高度的高度
$oFCKeditor->Create() ; // 创建编辑器
?>
下面是笔者创建好的实例代码,您可将代码保存为 add_article.php。
<?php
include("fckeditor/fckeditor.php") ; // 用于载入 FCKeditor 类文件
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用 PHP 调用 FCKeditor</title>
</head>

<body>
<form action="check.php" method="post" name="exapmle">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ; // 创建 FCKeditor 实例,可创建多个实例
$oFCKeditor->BasePath = './fckeditor/'; // 设置 FCKeditor 目录地址
$oFCKeditor->Create() ; // 创建编辑器
?>
<input name="ok" type="submit" value="提交" >
</form>
</body>
</html>
通过浏览里打开 http://you-address/add_article.php 查看 FCKeditor 安装效果。如图 3 所示。
图 3:FCKeditor 安装成功
注意:如果您想将 FCKeditor 创建为 HTML 结果代码,以便于在模板引擎里面调用(如
Smarty)可使用如下代码。
$output = $oFCKeditor->CreateHtml() ;
现在,您可通过 POST 方式获得编辑器的变量值。本例将表单的 action 设置为 check.php,
您可在 check.php 里使用代码
$fckeditorValue = $_POST['FCKeditor1'];
获得编辑器的变量值了。
FCKeditor 安装成功了。但是,我们还可以通过更多设置来使 FCKeditor 更加灵活人性
化。具体方法文本后面介绍。
3.2、用 JavaScript 调用 FCKeditor
调用 FCKeditor 必须先载入 FCKeditor 类文件,但与 PHP 调用方法不同,应用下面的代
码。
<script type="text/javascript"
src="./fckeditor/fckeditor.js"></script> <!--载入 fckeditor 类-->
载入 FCKeditor 类成功后,有三种方法创建(显示)编辑器。
剩余10页未读,继续阅读









安全验证
文档复制为VIP权益,开通VIP直接复制

评论1