Will creates nice web-things, builds awesome ideas, and collaborates with other creative types.

Home > Blog > Integrating CK Editor with CakePHP

Integrating CK Editor with CakePHP

by Will on Oct 24th 2010, 21:02

CkEditor is the new WYSIWYG editor from the maker of FckEditor – which has been one of the best editors around for a while now.

To use CkEditor instead of a boring old textarea input in your cakephp views all you have to do is follow these very simple instructions.

1. Download the editor from http://ckeditor.com/download

2. Unzip it and put the ckeditor directory into your webroot.

3. Include the javascript helper in your controller

Show Plain Text
  1. var $helpers = array('Html', 'Form', 'Javascript');

4. tell your view to include the ckeditor/ckeditor.js file

Show Plain Text
  1. link('/ckeditor/ckeditor', false);?>

5. Make sure your layout is looking for the javascript files variable like this:

Show Plain Text
  1. echo $content_for_layout;

6. replace your textareas with CkEditors by class name by adding the classname ‘ckeditor’ to your input.

Show Plain Text
  1. echo $form->input('content', array('class'=>'ckeditor'));

Hopefully thats got you a nice wysiwyg with all the buttons etc. Ckeditor is easy to configure to give your users as much or as little creative freedom as you need. Enjoy!

If you think there is a better way, or have a sugestion, post a comment and let me know.

Integrating CK Editor with CakePHP cakephp wysiwyg ckeditor

blog comments powered by Disqus