Set TinyMCE options with SilverStripeSet 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:

Comments

blog comments powered by Disqus