Limiting Wysiwyg Functionality

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 3, 2010   (RSS)

By ginger - September 2, 2010

Hi,

Is there a way to limit the functionality of a wysiwyg field? In other words, I'd like the customer to be able to use bold, italics, lists or headings, but I don't want them to be able to change the font and other things. I'd like most things to be controlled through a style sheet.

Is this an option, or is it all or nothing?

Thanks,
ginger

Re: [ginger] Limiting Wysiwyg Functionality

By Chris - September 2, 2010

Hi ginger,

Yes, you can customize the WYSIWYG by modifying cmsAdmin/lib/wysiwyg.php. Note the comment at the top that describes how to preserve your changes when you upgrade CMS Builder.

You can disable all but a subset of HTML by using the 'valid_elements' option. You'll need to turn on 'verify_html' as well. Change this:

verify_html : false, // allow all tags and attributes

...to this:

//verify_html : false, // allow all tags and attributes
valid_elements : 'p,br,strong/b,em/i,ul,ol,li,h1,h2,h3,h4,h5,h6',


You're also going to want to remove most of the buttons from the top of the WYSIWYG control. To do this, change this:

theme_advanced_buttons1 : "formatselect,fontsizeselect,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,|,removeformat,fullscreen",
theme_advanced_buttons2 : "forecolor,backcolor,|,link,unlink,anchor,|,blockquote,hr,image,media,table,|,pastetext,pasteword,|,code,|,spellchecker",
theme_advanced_buttons3 : '',


...to this:

theme_advanced_buttons1 : "formatselect,bold,italic,|,bullist,numlist,|,removeformat,fullscreen,|,pastetext,pasteword,|,code,|,spellchecker",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : '',
theme_advanced_blockformats: 'p,h1,h2,h3,h4,h5,h6',


I hope this helps! Please let me know if you have any questions.
All the best,
Chris