On Thursday, November 10, 2011 7:58:57 AM UTC-5, peter wrote:
>
> I have a couple of problems with 'text' fields in databases. I want to 
> be able to use a WYSIWIG editor, so I have set up ckeditor using the 
> instructions here 
>
> http://www.web2pyslices.com/slices/take_slice/18 
>
> This works fine, but there is no toolbar appearing with the editor. 
> How does one get the basic toolbar to appear?
>

You have to set the CKEditor options -- see it's 
documentation: http://ckeditor.com/
 

>
> If I succeed in getting this working and can embolden text etc. How do 
> I convert the text to html that reflects this emboldening?
>

You won't be converting text to HTML -- CKEditor itself generates HTML, 
which is what will get saved in the associated text field in the DB. The 
trick is how to get the HTML to display properly when you pull it from the 
DB and include it in the view. By default, web2py will escape the HTML, so 
it won't display as intended. To avoid that, use the XML() helper -- in the 
view, {{=XML(your_html_content)}}. Though this is dangerous if you are 
allowing users to enter the HTML because they can insert malicious 
Javascript. In that case, use {{=XML(your_html_content, sanitize=True)}}, 
though that will limit the allowed HTML tags and attributes. 
See http://web2py.com/book/default/chapter/05#XML.

Anthony

Reply via email to