3

We use CKEditor and CKFinder for Coldfusion in many of our CMS applications. These apps point to different sites on our server, so we want CKFinder setup to upload files to directories specific to each app. But we one want one shared location for the CKEditor and CKFinder files on the server.

In the config.cfm file, we have setup the default baseURL and baseDir like this:

config.baseUrl = "http://www.oursite.com/_files/site1/ckfinder_uploads/";    
config.baseDir = '\\ourserver01\_files\site1\ckfinder_uploads\';

In the header file for each app, we include the following to instantiate CKEditor and CKFinder (including the jQuery adapter):

<script type="text/javascript" src="/shared/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/shared/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript" src="/shared/ckfinder/ckfinder.js"></script>

<script type="text/javascript">
  $(document).ready(function(){
    CKFinder.setupCKEditor( null, '/shared/ckfinder/' );
  });
</script>

When I open a CKFinder window in one of the apps, it correctly opens to the default baseURL/baseDir. However, how can I override those defaults? I tried changing the CKFinder setupCKEditor function to the following with no luck:

CKFinder.setupCKEditor( null, { basePath:'/shared/ckfinder/', baseUrl:"http://www.oursite.com/_files/NEWSITE/ckfinder_uploads/", baseDir:"\\\\ourserver01\\_files\\NEWSITE\\ckfinder_uploads\\" } );

It just ignored this and used the defaults. Thoughts? Thanks!!

Nick Petrie
  • 5,364
  • 11
  • 41
  • 50
  • At this moment the only supported configuration options in the config object are: basePath, width and height, all other settings will not be used. – genericHCU Nov 28 '12 at 17:17
  • Dang @Travis beat me to it. I found the same thing [documented here](http://docs.cksource.com/CKFinder_2.x/Developers_Guide/ASP.NET/CKEditor_Integration) – Miguel-F Nov 28 '12 at 17:18
  • Same page I was on, copy cat! :P – genericHCU Nov 28 '12 at 17:19
  • That seems to be a half truth as example 2 includes the setting "rememberLastFolder" – genericHCU Nov 28 '12 at 17:24
  • can you use a custom config file? CKFinder.create( { basePath : '/ckfinder/', customConfig : '/myconfig.js' } ); The URL path for the custom configuration file to be loaded. If not overloaded with inline configurations, it defaults to the "config.js" file present in the root of the CKFinder installation directory. CKFinder will recursively load custom configuration files defined inside other custom configuration files. http://docs.cksource.com/ckfinder_2.x_api/symbols/CKFinder.config.html – genericHCU Nov 28 '12 at 17:39
  • I have to say, the CKSource docs are kinda crap. anyway, it looks like it may be possible to assign different IDs to configurations in the server side file. in the JS you specify the ID of the config to use. - CKFinder.config.id Since: 2.0 The id of CKFinder instance. An optional setting, that is usually used to distinguish various CKFinder instances in the server side configuration file. This way it is possible to use different baseUrl / baseDir depending on what id is passed to the server connector. var finder = new CKFinder(); finder.id = "myApplication"; – genericHCU Nov 28 '12 at 17:50
  • that came from http://docs.cksource.com/ckfinder_2.x_api/symbols/CKFinder.config.html – genericHCU Nov 28 '12 at 17:51
  • Thanks Travis. I created a config.js file. Based on the original config.js file that came with CKFinder, I added the following to my config.js: CKFinder.customConfig = function( config ){ alert("yo"); config.baseUrl = "http://www.oursite.com/_files/NEWSITE/ckfinder_uploads/"; config.baseDir = "\\\\ourserver01\\_files\\NEWSITE\\ckfinder_uploads\\"; When I open the CKFinder user interface, "yo" pops up, but the files from the default directory appear. Thoughts? – Nick Petrie Nov 28 '12 at 20:24

1 Answers1

1

Here's what I did. It's not perfect, but it works. With CF, there's a config.cfm file in the CKFinder directory where you set baseUrl and baseDir. There, I set the value of these two variables to two corresponding browser cookies. Then I set the cookie values in the headers of the different apps, so that they can reflect the app I'm in.

The downside is if you have 2 apps open, only the one you opened most recently will have the correct cookie values set. If anyone knows of a better, similar (or not similar) way of doing this, I'd be interested.

Thanks! Nick

Nick Petrie
  • 5,364
  • 11
  • 41
  • 50