Set TinyMCE options with SilverStripe
Posted January 5th, 2011 in PHP and SilverStripe
The SilverStripe/Sapphire CMS/Framework uses TinyMCE as the HTML editor. Normally to set configuration options for TinyMCE you would do it in your own tinyMCE.init() call, but in SilverStripe this is called dynamically in PHP in core Sapphire code. There's a simple way to add configuration options as shown in this post.
Set the options in mysite/_config.php
The following examples should be added to your main mysite/_config.php file.
Set a single option
To set a single option use the example below. The example sets the 'paste_text_use_dialog' TinyMCE option to false so that plain text pasting is done in a dialog instead of inline in the editor.
HtmlEditorConfig::get('cms')->setOption('paste_text_use_dialog', 'false');
Set multiple options with an associative array
The second example here sets multiple options using an associative array. The same option as above is set as well as my fake 'some_other_option' option.
HtmlEditorConfig::get('cms')->setOptions(array(
'paste_text_use_dialog' => 'false',
'some_other_option' => 'some_other_value'
));
Related posts:
- Replacing the TinyMCE paste plugin in SilverStripe 2.4 (Monday, December 12th 2011)
- Populate defaults dynamically with SilverStripe (Sunday, June 5th 2011)
- Making the Tree Tools sticky in SilverStripe (Friday, March 25th 2011)
- Use paste as plain text dialog in TinyMCE 3.3 (Friday, February 4th 2011)
- TinyMCE _mcePaste divs and Webkit browsers (Friday, December 10th 2010)

Comments
blog comments powered by Disqus