Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Content Editor Discussions /

Forum for content editors and CMS users.

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

How to disable the TinyMCE?


Go to End


6 Posts   4250 Views

Avatar
JulyCat

Community Member, 9 Posts

6 November 2009 at 8:28am

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

Avatar
yurigoul

Community Member, 203 Posts

10 November 2009 at 1:54pm

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.

Avatar
bummzack

Community Member, 904 Posts

10 November 2009 at 10:51pm

Edited: 10/11/2009 10:52pm

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

Avatar
yurigoul

Community Member, 203 Posts

10 November 2009 at 11:04pm

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.

Avatar
bummzack

Community Member, 904 Posts

10 November 2009 at 11:10pm

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.

Avatar
JulyCat

Community Member, 9 Posts

11 November 2009 at 9:33pm

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