Clone wiki

web2py_ckeditor / Home

CKEditor Plugin for web2py


Sometimes you just need a WYSIWYG editor. This plugin integrates CKEditor into web2py. It acts much like the Auth object in its usage. For example, in your model, you need to import and initialize it:

from plugin_ckeditor import CKEditor
ckeditor = CKEditor(db)

Basic Usage

It's most basic usage is to assign it to a Field widget:

    Field('title', length=255),
    Field('public', 'boolean', default=True),
    Field('text', 'text', widget=ckeditor.widget)

The CKEditor now automatically becomes available every time SQLFORM is used. This is a screen shot of it in action:

Main Window

This is great by itself, however, I decided to take it a few steps further. First of all, also supports edit in place. This is a test page to demonstrate:


To make this content editable, all it takes is the following line in the view:

{{=ckeditor.edit_in_place('.editable', URL())}}

This makes any element with the 'editable' class editable in place. It also requires a URL to save the data to when the save button is clicked. Here's what it looks like in edit mode:

Edit in Place

It is all AJAX enabled, spellchecks as you type, and it's fast. Edit in place is another great feature, but I also took it a step further than that and integrated upload and browse functionality for images and Flash movies:

Image Properties

Image Info

Browse Images

Image Upload Result

The upload and browse functionality is all taken care of by the plugin and does not require you to do anything on your end once you have initialized the plugin in your model as demonstrated above.


I used the following resources in developing this plugin, so a special thanks to the authors of these for providing the ground work required to make this possible: