问题
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!!
回答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
来源:https://stackoverflow.com/questions/13610474/customize-baseurl-and-basedir-in-ckfinder