Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Customise TinyMCE for one module

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

Page: 1
Go to End
Author Topic: 881 Views
  • NickA
    Avatar
    Community Member
    1 Post

    Customise TinyMCE for one module Link to this post

    I would like to enable a custom TinyMCE plugin / button that is restricted to one module. The documentation , http://doc.silverstripe.org/htmleditorconfig, indicates that this is possible by adding the following to your config

    HtmlEditorConfig::get('cms')->enablePlugins('../../tinymce_ssmacron'); // enables plugin
    HtmlEditorConfig::get('cms')->insertButtonsAfter('charmap', 'ssmacron');

    or by adding to getCMSFields() in your page.

    I have tried adding to the module page's getCMSFields() and the module's config with no success. However, it does work if added to the mysite config but, of course, the button then appears on all CMS pages.

    Has anyone else done this and, if so, would you be able to let me know what the pitfalls maybe.

    Comments on the documentation indicate that it may only work on /mysite/_config.php for some functions.

  • Emelkay
    Avatar
    Community Member
    2 Posts

    Re: Customise TinyMCE for one module Link to this post

    Hey NickA,

    I'm not completely sure of your use case here but would a conditional statement in the mysite/_config.php file do the trick in this instance?

    For example:

    // Have to use $_GET['url'] because the Director or SiteTree instance doesn't know where we are yet
    // All that we have is a url param that's been set by SilverStripe
    if(preg_match('/\/mypageurl/', $_GET['url']))
    {
       HtmlEditorField::get('cms')->doWhatever();
    }

    I'm very new here so apologies in advance if the answer is useless/incorrect

    Although, doesn't SS offer the ability to add a _config.php file to each module... Did adding it in there still not work?

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: Customise TinyMCE for one module Link to this post

    I did a custom tinymce for the jobboard module.

    https://github.com/fullscreeninteractive/silverstripe-jobboard/blob/master/code/Job.php#L94

    Hope that helps!

  • Emelkay
    Avatar
    Community Member
    2 Posts

    Re: Customise TinyMCE for one module Link to this post

    Ahh nice solution Willr, cheers!

    881 Views
Page: 1
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.