Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » HTMLEditorConfig - per Editor configuration - question from a humble n00b.

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2990 Views
  • mats
    Community Member
    5 Posts

    Re: HTMLEditorConfig - per Editor configuration - question from a humble n00b. Link to this post

    Mmh - Uncle Cheese's BootstrapForm Module rocks, but it did not help me with my problem...

    Instead I have - ahem probably - succeded in adapting CustomConfigHtmlEditorField to my needs:

    CustomHtmlEditorfield::create($DBObject, $Title, $NameOfExistingEditorConfig, $Value)

    This gives you a HtmlEditorfield based on a configuration $NameOfExistingEditorConfig.
    Edit: Above became obsolete, see below.

    To the best of my knowledge, this might be a pretty bad hack: I haven't really figured out Entwine (which seems pretty cool) and the PHP/JavaScript Interactions in the backend yet and I am not a programmer.

    Still, here's my code for CustomHtmlEditorfield. It might not be pretty but - for now - it works for me. Any criticism is very much appreciated. Maybe I just reinvented the wheel, but the advocated solutions did not work for me...

    Edit: Did not work as expected after all - created multiple invisible TinyMCE instances

    New approach:

    class CustomHtmlEditorField extends HtmlEditorField {

    protected $config = 'cms';

    public function __construct($name, $title = null, $value = '') {
          TextareaField::__construct($name, $title, $value);

    public function setConfig($config = 'cms') {
    $this->config = $config;
    return $this;

    function Field($properties = array()) {
    return parent::Field($properties);

    protected function include_customjs() {
    $configObj = HtmlEditorConfig::get($this->config);
    $configIdString = '_'.$this->config;

    Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
    $.entwine('ss', function($) {
    redraw: function() {
    var config = ssTinyMceConfig$configIdString, self = this, ed = this.getEditor();
    self.css('visibility', '');
    ed.create(this.attr('id'), config, function() {
    self.css('visibility', 'visible');
    ", 'htmlEditorConfig'.$configIdString);

    Editor configurations are now loaded via


    Well, i guess it's still a pretty crude hack

  • theruss
    Community Member
    2 Posts

    Re: HTMLEditorConfig - per Editor configuration - question from a humble n00b. Link to this post

    As a follow-up and as @mats found out, there is no way to have multiple HTMLEditorConfig's in SS 3.x out-of-the-box (As at March '14). Also, we shouldn't have to extend HTMLEditorField or HTMLEditorConfig to achieve this, so a core-patch will be required.

    I needed some functionality almost identical to @matt and after a chat with Hamish, I came up with the following:


    - Multiple HTMLConfig's defined in _config.php = check.
    - No additional fields = check.
    - Tested: Only FF and Chrome on OS X.
    - To add own config:

    1). Adapt/create your own config in your module's or mysite's _config.php file.
    2). Apply the patch from the repo above
    3). Add an extra boolean param to your HtmlEditorField construct call e.g.

    new HtmlEditorField('MyField', 'My label', 3, 20, true);

    4). Voila.


    1). While this framework patch does work as far as switching between PageTypes with differing HTMLEditorConfig's set goes, there is a small JS glitch when swapping between them. If you switch from a Page with a custom config, back to a Page using the default config (This on a CWP SS 3.1 site) you'll notice that TinyMCE's default dropdown templates show for the <paragraph> and <heading> dropdowns. Simply reloading the page, "fixes" this.

    2). This is untested in anything but Firefox and Chrome on OS X

    I'm guessing some sort of editor JS redraw needs to be called, but not sure at this point what or where as yet.


Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.