sábado, outubro 31, 2009

Integrando ckeditor com web2py


Using widgets in web2py (integrating CKEditor)

Although web2py comes with an integrated editor, I really like ckeditor and using it for a text field is trivial using widgets!

First, install ckeditor (put the ckeditor inside a js/ckeditor file in your static folder and include it) :

<script type="text/javascript" src="{{=URL(request.application,'static','js/ckeditor/ckeditor.js')}}"></script>

After that, we define a 'body' text field (or whatever name you like):

db.define_table('page',
# more Fields …
Field('body', 'text'))

Then, inside your db.py (or to another file in your models directory) put the widget:

def advanced_editor(field, value):
return TEXTAREA(_id = str(field).replace('.','_'), _name=field.name, _class='text ckeditor', value=value, _cols=80, _rows=10)

and use the widget

db.page.body.widget = advanced_editor

From now, SQLFORM will use ckeditor to show/edit/save data!

CkEditor in web2py


FONTE: http://jon.is.emotionull.com/post/227873650/using-widgets-in-web2py-integrating-ckeditor


--
Atenciosamente

--
=========================
Alexandre Andrade
Hipercenter.com

Nenhum comentário: