Fckeditor是一款功能强大且开源的HTML在线编辑器,在许多场合都会用到。要将其整合到Zend Framework中其实步骤很简单。
1. 下载最新版本的Fckeditor,然后解压缩至Zend Framework程序的 public
目录下的editor目录,删除其中不需要的js/perl/asp等文件。
2. Fckeditor为了兼容php4有两个可供调用的Fckeditor
class.考虑到Zend
Framework的PHP5的要求,直接删除fckeditor.php,fckeditor_php4.php这两个文件,并将fckeditor_php5.php重新命名成Fckeditor.php,将其移动到models目录下。
3.
在你的Controller文件中就可以直接调用了:
<?php
…
public function
xxxAction()
{
$editor = new Fckeditor(”content”);
//content为Fckeditor文本框的名字
$editor->BasePath =
$this->view->baseUrl.”/public/fckeditor/”;
$editor->Value =
“请在此处输入文章内容”;
$this->view->editor =
$editor->CreateHtml();
//调用CreateHtml方法产生html语句供视图模板调用。
$this->render();
}
在模板文件里 xxx.phtml
<?php echo $this->editor;?>
就可以显示Fckeditor的文本编辑器了!