发新话题
打印

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

本主题由 Hex 于 2008-2-27 12:06 移动

[1.5.4][范例] CI 集成 FCKeditor

传统最简单的方式是直接用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 来定义该值。
Fred Wu
thislab.com

TOP

顶!!!!

太感谢了:)呵呵,

TOP

不错,学习了:lol :lol

TOP

fckeditor
怎么选择支持中文

TOP

fckconfig.js 文件
QQ: 49489680
MSN: zhaochang_tj AT hotmail DOT com

TOP

再次感谢濸蓝

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

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

进入下一步环节。

//bow

TOP

提问:
$this->load->library('fckeditor', 'content');

这样的话,如何在一页里显示多个FCK?
CIAO,CI...

TOP

兄弟,你是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
程序人生,你我相伴!

TOP

好东西。。。收藏。。。:lol
CodeIgniter,JQuery,Ext
http://www.girlsgroup.cn

TOP

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/' ;

TOP

那天没中文,不好意思。多谢hex的翻译。

那天没中文,不好意思。多谢hex的翻译。

TOP

请问版主,你用的是哪个版本的fckeditor?

我这个版本的好象跟你的不一样,配置过程中第三步,没有的,能否把你的fckeditor放到共享里,10736061

TOP

引用:
原帖由 lony 于 2008-3-18 17:34 发表
提问:
$this->load->library('fckeditor', 'content');

这样的话,如何在一页里显示多个FCK?
复制内容到剪贴板
TEXT 代码:
$this->load->library('fckeditor', 'fckeditor1');



$this->fckeditor->BasePath = 'system/plugins/FCKeditor/';

$this->fckeditor->ToolbarSet = 'Basic';



$data['fck1'] = $this->fckeditor->CreateHtml();

       

$this->fckeditor->InstanceName = 'fckeditor2';

       

$data['fck2'] = $this->fckeditor->CreateHtml();



$this->load->view('mypage', $data);
[ 本帖最后由 sam 于 2008-10-16 18:03 编辑 ]
CodeIgniter,JQuery,Ext
http://www.girlsgroup.cn

TOP

:handshake :handshake :handshake

TOP

发新话题