Jump to:

22992 Posts in 11842 Topics by 2828 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: 2624 Views
  • Jimmis
    Avatar
    Community Member
    2 Posts

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

    Hi there,

    Just a quick question, any help would be greatly appreciated.

    Is it possible to customize the TinyMCE editor on a per 'TinyMCE Editor Field' basis?

    ie: I want 3 TinyMCE fields on a page, each one containing only certain buttons and allowed HTML tags etc.

    Thanks in advance.
    kind regards
    James

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

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

    You can set the htmleditorconfig values in the getCMSField. You can also have multiple htmleditor configs defined and swap between them when making your getCMSFields.

    $fields->addFieldToTab('Root.Main', new HtmlEditorField('Field'));
    HtmlEditorConfig::set_active('cms-small');
    $fields....
    HtmlEditorConfig::set_active('...');

  • muskie9
    Avatar
    Community Member
    9 Posts

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

    Hi all,

    Building off of this concept:

    Would anything change with setting the config for a front end form?

    I have created a new fieldset:

    $fields = new FieldSet(
             new TextField('Title', 'Product Name'),
             new CurrencyField('Price', 'Price'),
             new NumericField('TotalAvailable','Total Available'),
             new ImageUploadField('MainImage', 'Main Image'),
             new HTMLEditorField('Content', 'Product Description')
          );

    Would I still use something like HtmlEditorConfig::set_active('cms-small') after declaring the new fieldset?

    Thanks,

    Nic

  • Myrdhin
    Avatar
    Community Member
    67 Posts

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

    Hello Willr,

    I can't make your code works

    i tried this in my decorator object :

       public function updateCMSFields(FieldSet $fields) {
          // backup current HtmlEditorConfig identifier (is it usefull ?)
          $oldActiveConfig = HtmlEditorConfig::$current;

          $basicConfig = HtmlEditorConfig::get('basic');
          $basicConfig->setButtonsForLine(1, array('bold','italic','underline'));
          $basicConfig->setButtonsForLine(2, array());
          $basicConfig->setButtonsForLine(3, array());
          $basicConfig->setOptions( array(
             'friendly_name' =>'Basic HTML Editor'
          ));

          HtmlEditorConfig::set_active('basic');
          $HtmlEditorField = new HtmlEditorField("Presentation", _t('Presentation.SINGULARNAME', 'Presentation') );
          // restore old current HtmlEditorConfig identifier (is it usefull ?)
          HtmlEditorConfig::set_active($oldActiveConfig);

          $fields->addFieldToTab("Root.Main", $HtmlEditorField);
       }

    but all HtmlEditorFields in all Pages (in admin interface) are now 'basic'...

  • Myrdhin
    Avatar
    Community Member
    67 Posts
  • mightycoco
    Avatar
    Community Member
    3 Posts

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

    Thanks for the CustomConfigHtmlEditorField tip - that one is really a live-safer

  • mats
    Avatar
    Community Member
    5 Posts

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

    Has anybody successfully done different editor configurations in one form with 3.0? Somehow it's always the last active configuration that gets used for all HtmlEditorFields on the page... I aim to have two fields allowing only bold and italic formatting plus one full-fledged editor field in my form. Whatever i do though, i end up with having one config or the other on all three fields. Is there some way to apply a configuration per editor instance?

    Any help greatly appreciated,
    mats

  • muskie9
    Avatar
    Community Member
    9 Posts

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

    Here's a video tut by uncle cheese utilizing bootstrap forms with SS3. I think he goes through configuring the HTMLEditorFields:

    http://www.leftandmain.com/silverstripe-screencasts/2012/07/03/bootstrap-forms-for-silverstripe-3/

    2624 Views
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.