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.
Related posts:
- File Downloads With Zend Framework I have been handling file uploads in most of my...
- Zend Framework Modular Directory Structure Download I have been figuring out the Zend Framework for the...
- Zend Framework Conventional Directory Structure Download I have created this ZF Conventional Directory Structure - similar...
- Zend Framework: View File downloaded as Excel File This is basically a back-up post from my previous posts...
- Zend Framework without mod_rewrite in Windows Rob Allen posted an entry in his blog about using...
Related posts brought to you by Yet Another Related Posts Plugin.

Cool, I have a question for you, did you set this variable too: $Config[’UserFilesPath’] ? cuase if I don’t set it I can upload files and I can’t see the files browser, I got an error, something about that can’t create some folders.
the $Config[’UserFilesPath’] is set to /images/uploads
The full path to this - i think is - /home/ekini/public_html/images/uploads
It is found in the html folder of your ZF app.
/html
index.php (bootstrap file)
/js
/images
/uploads (CHMOD to 0777)
make sure you have the xml, js, php and other file extensions included the .htaccess list above though.
hope this helps. if there are still errors, just send a reply to this post and il double check my settings in my site.
-wenbert
Well, this is my .htaccess fike data:
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|pdf|eps|ai|doc|xls|ppt|zip|rar|sit|jpeg|swf|xml|xst|txt|js\.php|jar|php)$ index.php
Doesn’t work, still the framework thinks that folder is a controller/action. I’m using fckeditor 2.5.1, latest one. And this is the config in my php connector:
$Config[’Enabled’] = true ;
$Config[’UserFilesPath’] = ‘/userfiles/’ ;
// $Config[’UserFilesAbsolutePath’] = ‘/userfiles/’ ;
The problem is this, If I don’t set $Config[’UserFilesAbsolutePath’] with all the absolute path, doesn’t work, I mean, I got an error about that can’t create some folders, :S, you are using that variable ?
you have a typo in your .htaccess file.
check the |js\.php| part…
it should be |js|php|
no \.
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|pdf|eps|ai|doc|xls|ppt|zip|rar|sit|jpeg|swf|xml|xst|txt|js|php|jar|php)$ index.php
if that doesn’t work, i will check the files on the application when i get home. im still at work
hehehe, js.php is a special file :P, js + php to print some stupid constants and stuff with php.
Great stuff man.I have a slight problem though
My installation was a little bit different then yours. I like all my 3rd party libs under library folder. So I created the directory FCKeditor under library folder and put fckeditor.php fckeditor_php4.php and fckeditor_php5.php under this.rest of the files went to /httpdocs/scripts/FCKeditor
And in the controller/action
$oFCKeditor = new FCKeditor(’FCKeditor1′);
$oFCKeditor->BasePath = ‘/scripts/FCKeditor/’;
$oFCKeditor->Value = ‘Default text in editor’;
$returnHTML= $oFCKeditor->CreateHtml();
$this->view->editor = $returnHTML;
and of course in the phtml file
editor?>
suprisingly the editor comes and perfectly. all buttons work etc. but when I try to browse server for image upload I get
Error creating folder “redirt:index.php/” (can’t create directory: directory) message.
in the configuration file I have
$Config[’Enabled’] = true ;
$Config[’UserFilesPath’] = ‘/userimages’ ;
and of course the directory exists.
as I honestly believe that your are a genius, could you please help me on this one?
Thanks
B.
sorry, made a mistake
===========
and of course in the phtml file
editor ? >
Hello, hope ur doing fine. Is the directory writable? Have u chmod it to 777?
@jfalvarez well if ZF stil thinks that fckeditor is a controller then the .htaccess part is still sending stuff to index.php (boobstrap). Try double checking that part — htaccess
Hi wenbert,
This is a windows xp machine I am trying on, so I don’t think the permissing will be an issue.
hi Bilgehan,
can you check your apache error logs?
did u try removing the js.php? and just use .php instead? (in the .htaccess file)
i just had the same problem - ZF was looking for an fckEditor controller - the problem was that i forgot to edit the .htaccess file beside the index.php (bootstrap)
Wenbert, thanks for your time and help!
My htaccess file says
RewriteRule !\.(htm|html|txt|swf|js|ico|gif|jpg|png|css|php|xml)$ index.php
and apache error logs is clean.
you can check the page here
http://fmuw.dyndns.org/test/index/fck
Good news!
I have changed the config.php as follows
$Config[’UserFilesPath’] = ‘/user/’ ;
$Config[’UserFilesAbsolutePath’] = ‘C:/Documents and Settings/Bill/Desktop/v.2.subversion/httpdocs/user/’;
and everything works fine!
I hope this helps others.
Thanks again Wenbert.
Hi Bilgehan,
Thanks for your input!
I will put some notes regarding file paths for Windows machines…
It’s easier than that: just put a .htaccess file in your fckeditor folder with just RewriteEngine Off in it. That’s it
Thanks hendi!
I never thought of that… way better and easier solution…
You’re the machine!!. I´m spanish!!
You’re the best!!
Thank you!!!
more elegant version of .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
I just spend 3h looking for an answer about the FCK and ZF - it’s Windows case - the best solution is to set things like that:
$Config[’UserFilesPath’] = ‘/images/upload/’;
AND COMPLETLY COMMENT
$Config[’UserFilesAbsolutePath’]!!!!!!
Then it’s universal (working both on Win and Linux). Of course previously change .htaccess.
Ha!It worked for me too.The only thing that I didn’t found here is where exactly should I put my .htaccess with RewriteEngine Off..
So you should put it in JS folder. E.g. web_root/js/.htaccess
Tnx,u helped me a lot
Hi,
It seems hendi’s system is the best. But where to place FCKeditor folder? In application? or in the public folder of the site?
Thanks
Nearher,
You place it inside: public/js/FCKEditor
On your views/layouts, you can use the base_url to call the FCKEditor files.
Regards,
Wenbert
Hi,
I am new in zend…
I wann a integrate FckEditor in my application but first i am not getting this fckeditor folder to upload this in our Library folder ya somewhere ..?
and how to use that in model as well as in phtml file
Please give me that folder with step by step that i can implement this
i am using xampp