How to install CKEditor and CKFinder!!!

CKEditor and CKFinder

Hi Everyone,

As we all know there is no built-in rich text editor in default Drupal ike other CMS platforms, so what do we do? Well there is a solution in the form of Modules!!! those are CKEditor and CKFinder.

Today I'm going to show you how to setup CKEditor and CKFinder modules successfully.

[1] Download the Modules

First of all let's download all the necessary modules to our Computer. Open your web browser and type the URL http://drupal.org/project/ckeditor

and download the latest version of CKEditor module. Next open an another tab on your web browser and type the URL http://ckeditor.com/download and download the main files of CKEditor. the last module we need is file browser module so open one more tab on your web browser and type the URL http://ckfinder.com/download and download the PHP version of CKFinder. OK now we have all the necessary modules.

[2] Install the Modules

Now let's unzip (extract) the first downloaded CKEditor module from http://drupal.org/project/ckeditor and then open the unzipped  CKEditor folder
where you can see an another folder named same CKEditor which has only one text file in it (CKEditor/CKEditor/COPY_HERE.txt), if you open and read this text file you will understand that this the place where we have to put the CKEditor file which we have downloaded from http://ckeditor.com/download. So let's unzip the second CKEditor file and open the unzipped file then copy everything within this folder and paste into the CKEditor/CKEditor folder.

Now we have one more file to unzip which is CKFinder so let's unzip the CKFinder module and drag and drop or copy and paste to CKEditor folder (CKEditor/CKFinder). Now we have unzipped and arranged everything in order. Next we have to change some configurations to work CKFinder properly.

[3] CKFinder Configuration

So let's open config.php (CKEditor/CKFinder/config.php) and then comment or delete the line from 21 to 34.

function CheckAuthentication()
{
    // WARNING : DO NOT simply return "true". By doing so, you are allowing
    // "anyone" to upload and list the files in your server. You must implement
    // some kind of session validation here. Even something very simple as...

    // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
    // user logs in your system.
    // To be able to use session variables don't forget to add session_start().

    return false;
}

Note: To comment these codes just add /* at the beginning and */ at the end.(same as CSS comment)

Next in the same config.php file on line 61 ($baseUrl = '/ckfinder/userfiles/';)define the path to CKFinder userfiles.

Something like this $baseUrl = '/public_html/yoursitename.com/sites/all/modules/ckeditor/ckfinder/userfiles/';

Next step is to add this code require_once '../../../../includes/filemanager.config.php'; below the line 78 ($baseDir = resolveUrl($baseUrl);)

OK that's all we have to do with CKFinder/config.php. 

[4] Settings.php Configuration

The last step is to edit some sttings in settings.php, so go to drupal/sites/default/settings.php and on line 169 (# $cookie_domain = 'example.com';)

un-comment this line by removing # mark and change example.com to your domain name. Like this $cookie_domain = 'yourdomainname.com';

(Note: if you are on local computer add localhost $cookie_domain = 'localhost';).

Now everything is configured and it's time to put the CKditor module to drupal/sites/all/modules

(Note: There is no default directory named modules, you have to create a new folder called modules)

Let's open our Drupal site and go to /admin/build/modules and enable the CKEditor module.

Next go to /admin/user/permissions and set CKEditor access permission to authenticated user and CKFinder file upload permission.

Now go to /admin/settings/ckeditor and edit the advanced profile and set the file browser as type as CKFinder and save the configurations.

Now lets go and create a page or story and you can see instead of default plain text editor we have CKEditor and click on image button and you an see thast now you can browse for images and uploaded images and files to server from the site. Great!!!

I hope I could help all those who had problem for setting up CKEditor and CKFinder on Drupal.

If anybody got error while doing this please feel free to contact me I love to help you because I LOVE DRUPAL.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rossx34's picture

ckeditor Image Issue

Alright, everything seems to be alright with ckeditor and ckfinder except for one thing. When I upload an image, the Preview shows a red box with a white x in it. And if I save the page the image does not appear on the actual webpage.

I think I have narrowed down the problem after spending hours, no joke, searching many forums but I still have no solution.

The URL for the image is as follows:
//images/50x50%20Bodybuilding%20Workouts%20Link.jpg

If I remove one of the forward slashes and make the URL
/images/50x50%20Bodybuilding%20Workouts%20Link.jpg

THEN I can see the image in the preview fine and it even shows up in the Body code. However, if I save the page the image disappears yet again.

Please help,
Ross

megan's picture

Absolute path to uploaded files

Site Configuration > CK Editor select the Profile you are using

File browser settings > Absolute path to uploaded files:

Be sure the path starts w %d (server path to document root) for example
%d%b%f/uploads/%u

megan's picture

Absolute path to uploaded files

Site Configuration > CK Editor select the Profile you are using

File browser settings > Absolute path to uploaded files:

Be sure the path starts w %d (server path to document root) for example
%d%b%f/uploads/%u

Kristen's picture

Thanks a lot for this fine piece of work.

Thank you, THANK you, THANK YOU for your tutorial on how to get CK Editor and CK Finder working on Drupal 6.x.

It worked by the book - I only have one little suggestion about p. 4:

I highly suggest that you describe that they have to download the settings-php from their own website, and that the con't use the one downloaded with the Drupal 6.X. (Because if they do that their website will start all over again)

I learned it by the hard way - but found out to edit settings.php with my database name.

Anyway. I think you have made a very good,useful and explanational tutorial and I found that I could understand it.

Greeting from Denmark

Kristen

Dakshata 's picture

thanks!!!!

thanks alot for this instruction set.Its really helpful and easy to understand.,:)

G2k's picture

CKFinder $cookie_domain Access Denied problem

There's a problem when setting $cookie_domain = 'example.com'; because if I do that I keep getting an Access Denied response when I try to log into admin.
To solve this, all you need to do is add a "." before your domain. So it should look like:
$cookie_domain = '.example.com';

ciril's picture

I think you mis-understood

Dear G2k,

I am sorry for the late reply. You have to nter your own site domain name by replacing example.com.

Forexample in your case it shoud look lilke this below,

$cookie_domain = 'www.asia-gazette.com';

 

It will fix your issue.

Note: If you are using localhost for the development site then use localhost as your domain.

 

Still issues ask me, I will try my best to help you.

have a good day.

Piccoro's picture

CKEditor works but...

Your tutorial worked in Drupal 7, but if I change the file settings.php to:

$cookie_domain = 'www.mywebsite.com';

the "access denied" message appears when I try to log in to administration.

I was forced to comment back the line:

# $cookie_domain = 'www.mywebsite.com';

CKEditor appears to be working fine, but not CKFinder because I cannot upload images or browse my server.

Thanks for the tutorial anyway, Ciril ;)

G2k's picture

no, adding "www." gives me an

no, adding "www." gives me an access denied problem. Merely adding a "." has solved this problem for me.

Thanks!

Jun's picture

Error at production site

Hi Ciril,

I've test this module at my local and everything is work fine.
But when I try to use it at my production site, I can't upload any image.

Here is the error message i get after I click "Send it to server"

ERROR
The requested URL could not be retrieved

While trying to retrieve the URL: http://d120234322.u22.xlinternet.com.sg/modules/ckeditor/ckfinder/core/connector/php/connector.php?

The following error was encountered:

* Zero Sized Reply

Squid did not receive any data for this request.

Your cache administrator is webmaster.
Generated Mon, 20 Dec 2010 09:51:46 GMT by proxy (squid/2.7.STABLE3)

Is there any other setting I need to set at the production site?
Please advise.

Thanks.
Jun.

ciril's picture

There is no extra setup on live site

Hi Jun,

There is no extra setup to work on live site, everything is same.

May be you should try it again, you can watch m video tutorial for a live effect.

Read all the steps carefully double check everything is done correctly I am 100% sure that it will work whether it is live or local site.

 

Try again with more patience.smiley

Gilberto Ramos's picture

Thanks!

Thank you! Really helpful =)

ciril's picture

Happy to hear that

Happy to hear that you found my tutorial very helpful, and got working well. Best wishes for your Drupal works.

igameinfo.com's picture

File upload issue in D7

Will it resolve file uploading issue in D7.

By using this editor I wanna upload images in my post.

possible ?

if so then how - please give me a link so that I can work out.

Abbe Sennett's picture

went through your tutorial with ckfinder and it works perfect

Hi Ciril,

Thanks for the ckeditor and ckfinder tutorial. It works perfectly now!

By the way, did you get my other email? If you didn't please let me know. I was wondering if you do drupal 6 / php / theming freelance work?

Hope to hear back from you,
abbe

ciril's picture

I haven't got any emails

Thank you for the commends and happy to hear that I could help you through this small tutorial.

I do all kinds of works and especialy I love to do drupal works and SEO works.

Nicolas's picture

i got problems with security and HTML submittion

hi

thanks a lot for making the installation process as simple as you have done - really good!

i have followed all the info that i could find on this page and the video tutorial - but i get the following error while logged in as admin with all the permissions set.

while using CKEditor - it is fine but when i try to upload images to the server using CKFinder, the following error appears.

Upload cancelled for security reasons. The file contains HTML like data.

i have amended settings.php with base_url and cookie_domain

and the CKFinder config.php with the site's location for the files
but i can not understand this error at all.

any idea on what else i can try?

thanks,

Gopika's picture

Hello CIril, Thank you for a

Hello CIril,

Thank you for a nice tutorial with ckeditor.
I am working with drupal 7.
I am facing a small problem with image upload. The browse server button appears somtimes, and sometimes when I access the browse server button is not seen...
Do you have any idea why this is coming?

Thanks and Regards