Sunnysideup\MysiteSSUFlava\Forms\HTMLEditorFieldSmall
Sometimes you want two or more TinyMCE instances in the same page, and for each one to have it's own tinymce configuration. This class lets you do just that.
To use, pop something like this into your _config.php (this is a copy of what's in cms/_config, modified for
our purposes)
HtmlEditorConfig::get('linksonly')->setOptions(array(
'friendly_name' => 'Links Only',
'mode' => 'none',
'language' => i18n::get_tinymce_lang(),
'body_class' => 'typography',
'document_base_url' => Director::absoluteBaseURL(),
'urlconverter_callback' => "nullConverter",
'setupcontent_callback' => "sapphiremce_setupcontent",
'cleanup_callback' => "sapphiremce_cleanup",
'use_native_selects' => true, // fancy selects are bug as of SS 2.3.0
'valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class]",
'extended_valid_elements' => "",
'button_tile_map' => true
));
HtmlEditorConfig::get('linksonly')->enablePlugins(array('ssbuttons' => '../../../cms/javascript/tinymce_ssbuttons/editor_plugin_src.js'));
HtmlEditorConfig::get('linksonly')->setButtonsForLine(1, array('sslink'));
HtmlEditorConfig::get('linksonly')->setButtonsForLine(2, array());
HtmlEditorConfig::get('linksonly')->setButtonsForLine(3, array());
Then use this formfield in a form somewhere, passing the config name as it's first argument
function getCMSFields($fields = null) {
$tab->push(new CustomConfigHtmlEditorField('linksonly', 'RelatedLinks', 'Related Links', 3, 20));
}
Synopsis
- // methods
- public static void include_js()
- public void __construct()
Hierarchy
Extends
- SilverStripe\Forms\HTMLEditor\HTMLEditorField