oo 方式集成 fckeditor
参考hex老大的js调用fck方法,用类的方式实现1. 将下载的fckeditor文件放到index.php同级目录下,那么我的目录是这样的.D:\APMServ5.2.6\www\htdocs\mycode\fck
2. 在模型层建立一个fck类,将以下代码保存到fck.php文件中.
function fck_editor($name, $value='', $width='100%', $height='200'){
include_once("fck/fckeditor.php");
$fcked = new FCKeditor($name);
$fcked->BasePath = base_url().'fck/'; //此处要设置成绝对路径, 否则访问不到 fck目录。
$fcked->ToolbarSet = 'Default';
$fcked->Width = $width;
$fcked->Height = $height;
$fcked->Value = $value;
return $fcked;
}
3.控制器层代码如下
$cont = $this->fck->fck_editor('content');
$data['fckeditor'] = $cont->Create();
$this->load->view('admin/add_article', $data);
4.视图层: 在需要嵌入编辑器的地方加上<?php echo $fckeditor;?>
如果用 rewrite 隐藏过 index.php,请记得把fck目录从 rewrite 规则中排除,否则访问不到 fck目录。
呵呵,留着以后备用. 方法不错!加分! 为什么不用JS的方式呢?
页:
[1]