Allows per-editor TinyMCE configurations and body classes in SilverStripe
This module adds two features to HTMLEditorField in SilverStripe 3:
composer require nathancox/customhtmleditorfield
Example code:
<?php
// in _config.php:
// make a new TinyMCE config called "footer" by copying the default ("cms") config
$footerConfig = CustomHtmlEditorConfig::copy('footer', 'cms');
// remove the third row of the editor toolbar: no tables in the footer!
$footerConfig->setButtonsForLine(3, array());
// in getCMSFields()
// make an HtmlEditorField
$fields->addFieldToTab('Root.Footer', $footerField = new HtmlEditorField('FooterText', 'Footer'));
// assign the "footer" TinyMCE config to this field
$footerField->setEditorConfig('footer');
// set the editor's body class. This will make it class="typography footer-content"
$footerField->setBodyClass('footer-content');
If the config is defined in getCMSFields() it will only work if the CMS is opened or refreshed in the Pages section. Opening the window directly into another section such as Files and navigating to Pages will fail to load a config defined in getCMSFields.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem