Using FCKEditor with Zend Framework (File Browser Enabled)
Filed Under (General) by Wenbert on 28-11-2007
Tagged Under : fckeditor, Zend Framework
If you are trying to use FCKEditor with Zend Framework, you might be getting errors where ZF is trying to look for a controller named: “FCKEditor”.
To fix this, open your .htaccess file in your /html directory and add “xml” and “php”. Like something below:
RewriteEngine on RewriteRule !\.(htm|html|txt|swf|js|ico|gif|jpg|png|css|php|xml)$ index.php
This is so that all files with xml and php extension does not thrown to index.php - which is the bootstrap file of the Zend Framework. You might be asking why add “php” in the .htaccess. Well, FCKEditor has a built-in File Browser. The File Browser has connectors for different server side programming languages - and the default is PHP. So in short, there are PHP files inside the FCKEditor directories. It gets executed when you enable the File Browser in FCKEditor. And FCK also loads XML files. Adding both xml and php in the rewrite rule would allow FCKEditor to run properly inside a Zend Framework application.
The View File
Now, in your view file, you can have something like this:
-
-
< script type="text/javascript" >
-
window.onload = function()
-
{
-
if(document.getElementById(‘content_text’)) {
-
var oFCKeditor = new FCKeditor(‘content_text’) ;
-
oFCKeditor.BasePath = "< ?=$this->baseUrl ?>/js/fckeditor/" ;
-
oFCKeditor.Height = 500;
-
oFCKeditor.ReplaceTextarea() ;
-
}
-
}
-
< / script >
Notice the $this->baseUrl in the oFCKeditor.BasePath? Take note of it.
The File Browser Config
Now in /home/ekini/public_html/js/fckeditor/editor/filemanager/connectors/php/config.php I have UserFilesPath set to /images/uploads/ - see below:
$Config['UserFilesPath'] = '/images/uploads/' ;
Make sure the you have CHMOD to 777 the uploads directory.
Bilgehan, got his FckEditor working in Windows using the following config for FckEditor:
$Config[’UserFilesPath’] = ‘/user/’ ; $Config[’UserFilesAbsolutePath’] = ‘C:/Documents and Settings/Bill/Desktop/v.2.subversion/httpdocs/user/’;
Thanks Bilgehan
I hope that I didn’t miss anything. It took me more than an hour to figure things out ![]()
If you have comments, suggestions or corrections feel free to post them below.