Jump to:

5538 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » HtmlEditorField (tinyMCE) Questions

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

Page: 1
Go to End
Author Topic: 2908 Views
  • CodeGuerrilla
    Avatar
    Community Member
    105 Posts

    HtmlEditorField (tinyMCE) Questions Link to this post

    1) Is there a way to set the height for HtmlEditorField(s) ? As sometimes I would like to enable HTMLText but only have a small field doesn't really matter if I can't limit it

    2) Is there a way to modify tinyMCE's toolbar on a per field basis? Without hacking the core?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: HtmlEditorField (tinyMCE) Questions Link to this post

    Hi

    1) By setting the third parameter (rows) of the HtmlEditorField constructor (see code below for an example)

    2) In theory yes, practically no...
    The HtmlEditorConfig allows different configurations. Sadly, in the CMS only one (the active) configuration is considered.
    In the following code I define a "reduced" configuration and then toggle the configurations with
    HtmlEditorConfig::set_active('cms');. This seems to be bugged though, since TinyMCE configuration is only written once per "Page" and not per EditorField.

    HtmlEditorConfig::get('reduced')->disablePlugins('table');
    HtmlEditorConfig::get('reduced')->setButtonsForLine(1,
       'bold','italic','underline','strikethrough','separator',
       'formatselect','separator',
       'sslink','unlink','separator',
       'bullist','numlist','hr','charmap'
    );
    HtmlEditorConfig::get('reduced')->setButtonsForLine(2);
    HtmlEditorConfig::get('reduced')->setButtonsForLine(3);

    HtmlEditorConfig::set_active('cms');
    $htmlField1 = new HtmlEditorField('Text1', 'Text 1', 15);
    HtmlEditorConfig::set_active('reduced');
    $htmlField2 = new HtmlEditorField('Text2', 'Text 2', 15);

    Not sure if a per field configuration can easily be achieved or not. Maybe a core-dev could shed some light on this?

  • CodeGuerrilla
    Avatar
    Community Member
    105 Posts

    Re: HtmlEditorField (tinyMCE) Questions Link to this post

    Thanks banal will give it a try!

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: HtmlEditorField (tinyMCE) Questions Link to this post

    I'd love to see some light shed on this too..

    One source of customer frustration has been that tinyMCE's width is variable, and it can be difficult to see how a page will layout with images, etc, especially on a wide screen. Some page designs need more than one htmlEditorField at different widths. I have a css solution that fixes this problem, but if i try solving the problem using the HtmlEditorConfig class, i cant load seperate css docs into different HtmlEditorFields.

    -Chris

  • Devel0per
    Avatar
    Community Member
    5 Posts

    Re: HtmlEditorField (tinyMCE) Questions Link to this post

    thanks, banal this information is really useful.

    2908 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.