Monday, April 30, 2012

Re: cakePHP 2.1, ckeditor + ckfinder


For those that are having this problem as well, here is what I was able to do. This took a lot of trial and error on my part!

I have mine in:

app/webroot/js/ckeditor
app/webroot/js/ckfinder

I don't have anything special in my ckeditor config, just the default.

For ckfinder, here is my config:

* Put these lines at the top of the file after the <?php :
     * session_name('YOUR SESSION NAME'); - I found that my session name was NOT 'CAKEPHP' but what I have the cookie named.
     * session_start();

* In CheckAuthentication I have:
     *  if (!empty($_SESSION["Auth"])) { 
if(!empty($_SESSION['Auth']['User']['admin'])) {
return true; 
}
return false;
     * The only place that I use ckeditor and ckfinder is in my admin area, so I not only check
       for user logged in, but also for admin privileges as well. (Although, if it's configured properly
       non admin users shouldn't be able to reach that point anyway, just for added security.)

For the $baseURL:
     * $baseURL = '/path_to_cake_app/app/webroot/img/files/' - trailing slash required!!!
       (eg. '/test_dir/app/webroot/img/files/'
     * For the default ckfinder directory: '/path_to_cake_app/app/webroot/js/ckfinder/userfiles/'
     * I haven't tried this on my live host yet, but I would think that simply removing the leading path to the app
       would work in a production environment ('/app/webroot/...'), I should know shortly as I expect to turn this
       into production very soon.

For the $baseDir:
     * $baseDir = resolveUrl($baseUrl); - this is the default configuration and works well.

For the view:
     *  <?php echo $this->Form->input('body', array('id' => 'body', 'class' => 'ckeditor', 'label' => false)); ?>
<script type="text/javascript">
var CustomHTML = CKEDITOR.replace( 'body',
{filebrowserBrowseUrl : '/path_to_cake/app/webroot/js/ckfinder/ckfinder.html',filebrowserWindowWidth : '1000',filebrowserWindowHeight : '700'}
);
</script>

What I haven't quite figured out is how to turn the label off on the replaced editor. I have CSS that puts an asterisk (*) after required fields and it appears at the very bottom right after the editor window. Anyone have any ideas on how to remove the label from that? I assume it's being treated as a form field of it's own. I'm not as familiar with JS as I am PHP and CakePHP.

Any help with that little issue would be appreciated.

Elsewise, I hope this helps.

Sean

On Friday, April 27, 2012 2:21:45 PM UTC-4, Sean wrote:
Hello again,

I am working with cakePHP 2.1.0 and have incorporated ckeditor and ckfinder. I have gotten the editor window to come up and even gotten the ckfinder "Browse Server" button to work. What I am having problems with now is that when I hit the "Browse Server" button, the window opens, but gives me the dreaded "Folder not found. Please refresh and try again." error.

I have Googled, and RTFM, but to no avail. I'm not sure what else to do. I have tried using my own file structure, and using the default.

Here is some code:

/*
To make it easy to configure CKFinder, the $baseUrl and $baseDir can be used.
Those are helper variables used later in this config file.
*/

/*
$baseUrl : the base path used to build the final URL for the resources handled
in CKFinder. If empty, the default value (/userfiles/) is used.

Examples:
$baseUrl = '/userfiles/';

ATTENTION: The trailing slash is required.
*/
$baseUrl = '/js/ckfinder/userfiles/';

/*
$baseDir : the path to the local directory (in the server) which points to the
above $baseUrl URL. This is the path used by CKFinder to handle the files in
the server. Full write permissions must be granted to this directory.

Examples:
// You may point it to a directory directly:
$baseDir = '/home/login/public_html/ckfinder/files/';
$baseDir = 'C:/SiteDir/CKFinder/userfiles/';

// Or you may let CKFinder discover the path, based on $baseUrl.
// WARNING: resolveUrl() *will not work* if $baseUrl does not start with a slash ("/"),
// for example if $baseDir is set to  http://example.com/ckfinder/files/
$baseDir = resolveUrl($baseUrl);

ATTENTION: The trailing slash is required.
*/
$baseDir = resolveUrl($baseUrl);

At the moment, I have authentication turned off. I don't think it will matter as this is in the admin area which has NO public access. Only myself and another admin. 
I have tried to use authentication and couldn't get that working either.

I just don't know what these settings should be. I really like cakePHP, but getting ckfinder has been REALLY mind-blowing. 
I made this conversion b/c my old FCKeditor didn't work when I ported over from 1.2

Any help would be appreciated.

Thanks

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: