Wednesday, June 11, 2008

TinyMCE Basics

I spent a good deal of time searching the web yesterday. I was trying to remember how to make the TinyMCE WYSIWYG editor allow all HTML tags. If you've never heard of this editor, it is an excellent AJAX based editor for your websites. I use it to allow my clients the ability to edit and create HTML on-the-fly without any knowledge of Javascript. Basically, it displays HTML as an OpenOffice (or Word) document would. You can simply highlight text and make it bold, italic, or underlined. It also allows the ability to post photos (as long as the photo is on the web) and much more.

The key to allowing straight HTML is to include the following configuration at the top of your webpage. TinyMCE will take any textarea and make it into a nice editor.

tinyMCE.init({
...
valid_elements : "a[href|target=_blank],strong/b,div[align],br"

})



Above is a basic configuration to allow certain html elements. In order to allow a more flexible amount of elements, just follow this link: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements

Simple, eh...too bad I wasted some time searching for it when the answer was right in front of me...

No comments:

Post a Comment

Please leave a comment...