用户
 找回密码
 入住 CI 中国社区
搜索
查看: 21712|回复: 30
收起左侧

[插件 Plugin] [1.5.4][范例] CI 集成 FCKeditor

[复制链接]
发表于 2008-2-10 17:07:56 | 显示全部楼层 |阅读模式
传统最简单的方式是直接用php的过程式编程方式,用 include 或 require 来调用fck的文件。

但是既然CI绝大部分是OO的,那么我们也就尽量用OO的方式来集成fckeditor。

1. 下载解压fckeditor。将文件放在随便哪个目录,我自己是放在 ./plugins/fckeditor/ 下。

2. 接着,按照你的php版本,将fckeditor_php4.php或fckeditor_php5.php复制到 ./system/application/libraries/ 下并更名为 fckeditor.php

3. 打开此文件,将类名更改为 Fckeditor

4. 打开 ./plugins/fckeditor (或者你自己选择的目录)下的 fckeditor.php,复制 FCKeditor_IsCompatibleBrowser() 里的 所有内容,拷贝替换到 ./system/application/libraries/fckeditor.php 里的 IsCompatible()。

5. 修改 ./system/application/libraries/fckeditor.php 的 constructor 里的 basepath 定义。比如我的 ./plugins/fckeditor 就如此定义:
PHP复制代码
$this->BasePath = base_url().'/plugins/fckeditor/' ;
复制代码


6. 设置完毕!在控制器里如此调用就可以了:
PHP复制代码
$this->load->library('fckeditor', 'content');
$this->fckeditor->Value = $some_object->content;
$data['fckeditor'] = $this->fckeditor->CreateHtml();
复制代码


view里用 <?=$fckeditor?>就可以了。

其中调用library时的第二个参数是$_POST的key。如此就能用 $this->fckeditor->Value 来定义该值。
发表于 2008-2-10 17:13:59 | 显示全部楼层
顶!!!!

太感谢了:)呵呵,
发表于 2008-2-10 21:40:20 | 显示全部楼层
不错,学习了
发表于 2008-2-12 08:09:32 | 显示全部楼层
fckeditor
怎么选择支持中文
发表于 2008-2-18 10:25:39 | 显示全部楼层
fckconfig.js 文件
发表于 2008-2-18 22:18:08 | 显示全部楼层

再次感谢濸蓝

按照你的步骤,已经成功调用fck...

全部过程不超过10分钟,呵呵

进入下一步环节。

//bow
发表于 2008-3-18 17:34:02 | 显示全部楼层
提问:
$this->load->library('fckeditor', 'content');

这样的话,如何在一页里显示多个FCK?
发表于 2008-4-1 08:09:58 | 显示全部楼层
兄弟,你是fckeditor是什么版本啊,我的怎么和你的不一样呢,
我的fckeditor.php文件的代码如下没有找到你教程上面说的那个

PHP复制代码
 
<?php
if ( version_compare( phpversion(), '5', '<' ) )
        include_once( 'fckeditor_php4.php' ) ;
else
        include_once( 'fckeditor_php5.php' ) ;
?>
 
复制代码


而我猜想,改成如下

PHP复制代码
 
<?php
if ( version_compare( phpversion(), '5', '<' ) )
        include_once( base_url().'system/plugins/fckeditor/fckeditor_php4.php' ) ;
else
        include_once( '/plugins/fckeditor/fckeditor_php5.php' ) ;
?>
 
复制代码


但是出现如下错误


0
Fatal error: Cannot instantiate non-existent class: fckeditor in d:\appserv\www\blog\system\libraries\Loader.php on line 867

点评

cool  发表于 2011-6-1 07:48
发表于 2008-4-2 07:33:51 | 显示全部楼层
好东西。。。收藏。。。
发表于 2008-4-11 10:01:35 | 显示全部楼层

tips

if you are using .htaccess
you have to add "system/plugins/fckeditor" to the rewrite condition
like this:
RewriteCond $1 !^(index\.php|system/plugins/fckeditor)

and in my situation if have to set the base path like:
                $this->BasePath         = base_url().'system/plugins/fckeditor/' ;

---------------
Hex 翻译中文版如下:

如果你使用 .htaccess 的话,你应该添加“system/plugins/fckeditor”到 rewrite 条件中,
例如:
RewriteCond $1 !^(index\.php|system/plugins/fckeditor)
       
而在我的情况下,要像这样设置 base path:
$this->BasePath         = base_url().'system/plugins/fckeditor/' ;

本版积分规则