Integrating a file browser into ckeditor & CakePHP
Although there isn’t a file browser built into CKEditor, they do have a tool you can download. Unfortunatly they charge for it. Boo.
There are a few alternatives on the web however, so I have selected the best, and integrated it with CkEditor in my cakePHP powerd CMS.
Download the file manager from the nice chaps at core five: http://labs.corefive.com/Projects/FileManager/
Install that in a subdirectory of ckeditor
Follow the instructions and set up your filemanager.config.js like this:
Show Plain Text- // Set this to the server side language you wish to use.
- var lang = 'php'; // options: lasso, php, py
- // Set this to the directory you wish to manage.
- var fileRoot = '/app/webroot/somedir/';
- // Show image previews in grid views?
- var showThumbs = true;
Then, nip over to your filemanager.config.php file and set this up:
Show Plain Text- function auth() {
- {
- return true;
- }
- return false;
- }
Make sure you set your timezone and any other configs you need.
Now open up your CkEditor config.js and set up the editor to use the filemanager by default. Here is my config.js so there is no confusion:
Show Plain Text- CKEDITOR.editorConfig = function( config )
- {
- // Define changes to default configuration here. For example:
- // config.language = 'fr';
- config.uiColor = 'green';
- config.width = '500';
- config.filebrowserBrowseUrl = '/ckeditor/filemanager/index.html';
- config.filebrowserImageBrowseUrl = '/ckeditor/filemanager/index.html?type=Images';
- config.filebrowserFlashBrowseUrl = '/ckeditor/filemanager/index.html?type=Flash';
- config.filebrowserUploadUrl = '/ckeditor/filemanager/connectors/php/filemanager.php';
- config.filebrowserImageUploadUrl = '/ckeditor/filemanager/connectors/php/filemanager.php?command=QuickUpload&type;=Images';
- config.filebrowserFlashUploadUrl = '/ckeditor/filemanager/connectors/php/filemanager.php?command=QuickUpload&type;=Flash';
- config.toolbar_Full =
- [
- ['Bold', 'Table', 'Format' ,'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-', 'Image', 'Style', '-', 'Source']
- ];
- };
Thats it, fire up your page with CkEditor, hit the image button, and there will be a browse server button. click that and up comes the manager. Hit the grid or table buttons to see all your images!
Credits
Obviously Core 5. Good job guys!
This chap helped me out with auth section:
