Thursday, October 14, 2010

Configuring CKFinder in CFWheels

Russ Johnson has created a really nice plugin for ckeditor and markitup for CFWheels.

But I was using CKFinder on a project recently, and could not configure it with the jquery installation of ckeditor in the plugin.

So what I did was

install ckeditor (3.4.1) in the files directory
/files/ckeditor
then install ckfinder in the ckeditor directory
/files/ckeditor/ckfinder

then add the links to the javascript in the head of my main layout page
Since I use two environments, I did a check for my CGI.HTTP_HOST to make sure the paths are correct




If you aren't using two environments, you can include them in your javaScriptIncludeTag

then below the contentForLayout() tag, I added the javascript




Then every textarea that I need to use, I just use
textareaTag( name="editor1" )
It's not built into wheels like Russ' plugin so I can't use it as an object, but it's a simple matter to add
<cfset params.mycontroller.myfieldname = params.editor1> in my create or update actions


In my files/ckeditor/ckfinder/config.cfm file I had to make a few adjustments:


For testing purposes only, in my CheckAuthentication()
function, I returned true


You have to set your baseURL (the default is to use the userfiles folder in ckeditor


config.baseUrl = "/files/ckeditor/ckfinder/userfiles/";



and for some reason, I kept getting a file upload is corrupted message, so had to set


config.secureImageUploads = false ;



That was it. Pretty simple really.

3 comments:

CS said...

Followup - starting getting a "Unable to create temporary file" error when clients uploaded to the server. Had to change ckeditor/ckfinder/config.cfm config.tempDirectory = GetTempDirectory(); to config.tempDirectory = 'temp'; and create a temp folder in the root of the site. Then had to do a server refresh. Very nasty!

Unknown said...

Cathy, I followed your steps, but was curious if you had this error after setting everything up:

uncaught exception: [CKEDITOR.editor] The instance "editor1" already exists.

If you did, how did you fix it? There are some solutions out there that people have had success with, but have not worked for me.

CS said...

Hi Dave, no haven't had that error. I have had lots of problems with configuring ckfinder, and finally opted for another solution.
I will try to find time to post my code here if you are interested.
I am using this file manager:
http://labs.corefive.com/Projects/FileManager/