I've been using FCKEditor in my app for the past couple of years, from just before the 2.3 series came out.
One of the first things I did was figure out how to hack it to make the filemanager look at different directory structures based on user settings.
I snagged the 2.5b download the other day, threw it up on my dev server, and started trying to apply the same hacks - but found some differences in the new version that I had to work around. I figured I'd share.
(The following applies to the the CF code version.)
*****
First, somewhere in your code prior to calling FCKEditor, have this code:
<cfset request.FCKEditor = StructNew()>
<cfset request.FCKEditor.userFilesPath = "/your/desired/path">
(If you wish, you can also set "ServerPath" this same way, as opposed to setting the hardcoded variable in config.cfm below.)
Second, open the file editor/filemanager/browser/connectors/cfm/config.cfm in your editor of choice.
Set Config.ServerPath appropriately as needed, based on your file system setup.
Here comes the fun part... the first part of config.cfm is a large <cfscript> block, followed by some code inside a try/catch block and another small <cfscript> block that looks for varying data structures and if they are present, scoops up the variables within and applies them to the "Config" scope.
The trick is - the variables telling FCKEditor where to look for files, what path to apply to files when chosen in the browser, happens in the large <cfscript> block - BEFORE any variables that could alter the default paths are applied.
So - take the large <cfscript> block and split it. Find the line where Config.HtmlExtensions is set. Leave that line and the code above it alone. Grab the remaining script code and move it to the bottom of the existing code (adjusting open/close <cfscript> tags, 'natch). This will allow variables passed in to be detected prior to the various path variables being set.
---------
Within the try/catch block code - there' s code that begins with
<cfif isDefined("application.FCKeditor") and isStruct(application.FCKeditor)>
Make that a <cfelseif> tag, and add this code immediately prior:
<cfif isDefined("request.FCKeditor") and isStruct(request.FCKeditor)>
<cfset variables.FCKeditor = request.FCKeditor>
This will sniff out your passed-in "UserFilesPath" variable and use it.
-----------
In the lines in that moved script code - you'll find struct key variables being set in "Config.FileTypesAbsolutePath" for each of the four file types (image, file, etc). I had to tweak the code that set these variables to get the desired result.
The default code is like:
Config.FileTypesAbsolutePath["Image"] = iif( Config.ServerPath eq "", de(""), de(Config.ServerPath & 'image/') ) ;
but that code only looked at "ServerPath" and completely ignored "UserFilesPath" - both are needed. Also, since Config.ServerPath is set at a blank value at the top of the script, I thought the way the IIF() was set up was kinda silly, so I ditched it.
Config.FileTypesAbsolutePath["Image"] = Config.ServerPath & Config.UserFilesPath & 'image/';
*********
Give it a try yourselves, if you're so inclined, and share your victories/woes here.
--Scott
Thu, 11/15/2007 - 14:07
#1