具體的看FCKedit 官方文檔,這裡只記下了在ZF中的使用要點
一、表單產生
1.這裡是在控制器中的動作:public function fckeAction(){
$oFCKeditor = new FCKeditor('FCKeditor1');
$oFCKeditor->BasePath = '/fckeditor/'; //must add .htaccess file in fckeditor directory, the content of this file only include 'RewriteEngine off'
$oFCKeditor->Width='600';
$oFCKeditor->Height='400';
$oFCKeditor->Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ;
$this->view->fckeditor = $oFCKeditor; //->Create() ; //in this controller, not to call FCKeditor->Create(), call it must in view page
$this->render();
}
2.在 fcke.phtml 中:
<form name="test" action="/test/getfck" method="POST">
<ul>
<li>使用者: <input type="text" name="userName" value="" /></li>
<li>密碼: <input type="password" name="password" value="" /></li>
<li>
<?php
echo $this->fckeditor->Create();
?>
</li>
</ul>
<ul>
<li><input type="submit" value="提交" /><input type="reset" value="取消" /></li>
</ul>
</form>
二、獲得表單值:
1.控制器中的動作public function getfckAction(){
$this->view->userName=$sUser=$_POST['userName'];
$this->view->password=$_POST['password'];
$this->view->fckeValue =$_POST['FCKeditor1'];
$this->render();
}
2. getfck.phtml<?php
echo $this->escape($this->userName).'<br/>';
echo $this->escape($this->password).'<br/>';
echo $this->fckeValue.'<br/>'; //the FCKeditor already call htmlspecialchars() in fckeditor_5.php, not to use escape() on the view page;
?>
三、關鍵事項:
1.
在 fckeditor 目錄、你要放上傳檔案的 userfiles 目錄,以及其它不用解析的public 目錄(我的這三個目錄同入口檔案 index.php 一起放在html 目錄下)裡要加上 .htaccess 檔案,如下:RewriteEngine Off
2.
圖片上傳:
功能開啟
編輯 fckeditor/editor/filemanager/connectors/php/config.php $Config[’Enabled’] = true ;
四、在FCKeditor 2.6中。發現在上傳檔案過程中,通過瀏覽伺服器按鈕開啟的頁面來上傳,與直接點上傳按鈕後,這兩種情況會有不同的結果---傳到伺服器不同的目錄裡,前者要傳到 image 目錄下,後者卻直接傳到
userfiles 目錄下,可能是個 bug。