Jump to:

520 Posts in 248 Topics by 263 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » How to disable the TinyMCE?

Forum for content editors and CMS users.

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

Page: 1
Go to End
Author Topic: 2617 Views
  • JulyCat
    Avatar
    Community Member
    9 Posts

    How to disable the TinyMCE? Link to this post

    All greetings!
    Tell me, please, is there any way to completely disable the TinyMCE?

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: How to disable the TinyMCE? Link to this post

    You could replace your Content field with a new textareafield in the model using getCMSFields().

    The only problem would be that the text you enter would not have any formatting, not even line breaks.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: How to disable the TinyMCE? Link to this post

    Yes, replace the TinyMCE Editor with a TextArea, just as yurigoul said.
    It will keep line-breaks, if you set the Content field to 'Text' instead of 'HTMLText'.

    Here's how your Page class could look like:

    class Page extends SiteTree
    {
       public static $db = array(
          'Content' => 'Text'
       );
       
       public function getCMSFields(){
          $fields = parent::getCMSFields();
          $fields->removeFieldFromTab('Root.Content.Main', 'Content');
          $fields->addFieldToTab('Root.Content.Main', new TextareaField('Content', 'Content', 20));
          return $fields;
       }
    }

    You can even use BBCode syntax for formatting if you use the following statement in your template:

    $Content.Parse(BBCodeParser)

    Update You'll have to run /dev/build if you change the class as shown above

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: How to disable the TinyMCE? Link to this post

    My guess is that it only shows the line breaks in the output on the site if you wrap it in <pre> tags, unless you use BBcode.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: How to disable the TinyMCE? Link to this post

    No, line-breaks will get converted to <br/> if your field type is 'Text'. No need for a wrapping <pre> tag or the BBCode parser.

  • JulyCat
    Avatar
    Community Member
    9 Posts

    Re: How to disable the TinyMCE? Link to this post

    Thank you for your help! Your advice is very useful.

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