When ColdFusion 8 packaged FCK Editor as part of the default installation, we were very excited to move to it instead of the WYSIWYG editor we had been using before, but our first project required the use of a thumbnail viewer. Enter CKFinder, which worked well for us except that the file directory was set up as global for every situation it was used in! This wouldn’t work for us; we have a number of clients and each has their own file areas. To get the project finished we initially hard-coded the location, but after a lot of Web searching and experimenting we found out how to get it to work with our other sites.
First, in order to make it easy to change the baseUrl, we decided to use client variables, which we could <cfset> in our .cfm file just before the <cftextarea> tag. We added this code near the top of the config.cfm file:
<cfif IsDefined("client.baseUrl")>
<cfset baseUrl = client.baseUrl>
<cfelse>
<cfset baseUrl = "/UPLOAD/">
</cfif>
This was mostly a matter of convenience. Later on, inside the cfscript:
config.baseUrl = "#baseUrl#";
Once we made these changes, we tried it out and found out that it did not work! The problem turned out to be that client variables were not available to config.cfm, and we realized why after reading this:
http://docs.fckeditor.net/CKFinder/Developers_Guide/ColdFusion/Configuration/Sessions
We added an application.cfm file matching the ones used in the rest of the site to our ckfinder directory. At that point we had our client variables, but CKFinder actually would break later on! The reason was because we had to change the settings in the application files in this directory:
ckfinder/core/connector/cfm/
We changed the application name, added our client variable storage entry and a few other odds and ends to the file, and then we were ready to go. So now we can create an FCK Editor instance (including custom file path) with the following two lines of ColdFusion:
<cfset client.baseUrl = "/UPLOAD/path/to/the/files/">
<cftextarea id="text" name="text" richtext="true" />
Wed, 12/03/2008 - 22:02
#1
Re: Custom image paths with CF
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+