Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » [solved] HTML Editor Configuration doesn't seem to work for me

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
Go to End
Author Topic: 2188 Views
  • banal
    Avatar
    Community Member
    901 Posts

    [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Hello all

    I'm creating a website where I'd prefer to have different WYSIWYG-Editor configurations for different user-groups. Apparently, the CMS already supports that, by allowing the admin to specify a "HTML Editor Configuration" in the "Security" > "Permissions" tab.

    The CMS sees my configurations and also displays them in the dropdown. Everything seems to be saved just fine, but the CMS doesn't apply the settings. It always uses the default configuration.
    Is there something I have to do myself here? Get the current user-group and apply it's editor config?

    Any insight would be appreciated. Thanks

  • banal
    Avatar
    Community Member
    901 Posts

    Re: [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Figured it out.
    Member->getHtmlEditorConfigForCMS() looks up the editor config to use.
    It selects the best editor config based on priority.. so if you don't set a priority for your config, you will always end up with the default config.

    The following solved the problem (default priority is 0):

    HtmlEditorConfig::get('customConfig')->setOption('priority', 1);

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Banal,

    Could you explain how you managed to get the result of your first post in this thread. How did you create a custom HTML Editor Configuration and where did you put it?

    Thanks!

  • banal
    Avatar
    Community Member
    901 Posts

    Re: [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Sure. A good place to define these configurations is in _config.php. Here's an example:

    // NORMAL CONFIG
    HtmlEditorConfig::get('cms')->disablePlugins('table', 'contextmenu');
    HtmlEditorConfig::get('cms')->setButtonsForLine(1,
       'bold','separator','pastetext','pasteword','separator','undo','redo','separator',
       'sslink','unlink','separator','bullist','numlist','charmap'
    );
    HtmlEditorConfig::get('cms')->setButtonsForLine(2);
    HtmlEditorConfig::get('cms')->setButtonsForLine(3);

    // ADMIN CONFIG
    // create a new config named "admin"

    $cfg = HtmlEditorConfig::get('admin');

    // set the name for the config dropdown
    $cfg->setOption('friendly_name', 'Administrators');

    // set the config priority (must be bigger than 0)
    $cfg->setOption('priority', 1);

    // enable some of the required plugins for silverstripe
    // @see /cms/_config.php for the default config!

    $cfg->enablePlugins('media', '../../tinymce_ssbuttons', 'fullscreen');

    // customize your buttons here.. similar to example above?

    After doing so, you should be able to select the config for each Member-Group (in the Permissions tab).
    I don't know, if this is all the same in 2.4 though. Didn't try it yet. Also have a look at /cms/_config.php and the HtmlEditorConfig class to get some pointers how this all works.

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Many thanks!

    I ended up with just overwriting the existing HTMLEditorConfig for a most simple WYSIWYG editor.

    // Set custom TinyMCE configuration
    HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats','p,h1');
    HtmlEditorConfig::get('cms')->setButtonsForLine(1,'undo, redo, separator, cut, copy, pastetext, separator, ssimage, sslink, unlink, separator, fullscreen, advcode, formatselect');
    HtmlEditorConfig::get('cms')->setButtonsForLine(2);
    HtmlEditorConfig::get('cms')->setButtonsForLine(3);

  • forester
    Avatar
    Community Member
    4 Posts

    Re: [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Hi all,

    I've just the same problem, but my solution doesn't change anything....

    I just want to remove some buttons of the tinyMCE:

    I've tried:
    $cfg = HtmlEditorConfig::get('cms');
    $cfg->setOption('priority',1);
    $cfg->setButtonsForLine(1,'bold','underline','strikethrough','separator','justifyleft','justifycenter','justifyright','justifyfull','formatselect','separator','bullist','numlist','outdent','indent','blockquote','hr','charmap');
    $cfg->setButtonsForLine(2,array('undo','redo','separator','cut','copy','paste','pastetext','pasteword','spellchecker','separator','advcode','search','replace','selectall','visualaid','separator','tablecontrols'));
    $cfg->setButtonsForLine(3);

    but there are still buttons in the third line and there is still the italic-button in the first

    I would be very grateful for further assistance!

  • forester
    Avatar
    Community Member
    4 Posts

    Re: [solved] HTML Editor Configuration doesn't seem to work for me Link to this post

    Sry...i found my mistake!

    Too much ' ... only one ' at the beginning and one at the end!

    I'm so st***!

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