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.

Archive /

Our old forums are still available as a read-only archive.

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

I don't want WYSIWYG


Go to End


6 Posts   4745 Views

Avatar
tomasulej

Community Member, 2 Posts

13 June 2007 at 6:12am

I would like to write my articles in source code mode instead of WYSIWYG. But how to do that? Maybe you answer me "use HTML button in editor", but when I do that, my code is changed after loading to WYSIWYG - for example all national symbols (like "ô","ä","č","ľ" etc.) are changed to entities ("aa;culate;" etc.), and some tags then don't work properly...

Can you help me! Many thanks

Avatar
Sam

Administrator, 690 Posts

13 June 2007 at 11:13am

In your page class, you will need to remove the HTMLEditorField and add a TextAreaField.

class Page {
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root.Content.Main', 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextareaField('Content'));
}
}

See http://doc.silverstripe.com/assets/classes/default/TextAreaField.html for more information on what you can do with the TextareaField.

You should be aware that this will insert whatever you type into the TextareaField straight into your template, without validation. It's fine if you know what you're doing, but if you're handing this over to a non-technical author you'll want to make sure they use the draft site tool! :-)

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

7 July 2007 at 5:24pm

Hi Sam,

Thanks for this! Disabling the WYSIWYG can be quite nice. :)

As per development-guidelines:removefieldfromtab, this line is needed at the end of the getCMSFields() function:

return $fields;

Otherwise you will get this error:
Fatal error: Call to a member function push() on a non-object in /sites/test.silverstripe.com/elofgren/cms/code/CMSMain.php on line 268

Took me a few minutes to figure out why. ;)

New bbcode is nice! :)

Good night,

Elijah

Avatar
Sam

Administrator, 690 Posts

8 July 2007 at 9:41pm

Elijah: Usability applies to programmers, too!

Do you perhaps want to add a check to CMSMain, where it calls getCMSFields(). If $fields returns null, have an error along the lines of

"getCMSFields returned null on a 'Page' object - it should return a FieldSet object. Perhaps you forgot to put a return statement at the end of your method?"

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

9 July 2007 at 1:22pm

Thanks Sam! :)

------------------------------------------------------------------------
r38115 | elofgren | 2007-07-08 20:21:20 -0500 (Sun, 08 Jul 2007) | 1 line

Display a useful error message if getCMSFields() returns null. Thanks Sam: http://www.silverstripe.com/general-discussion/flat/1537?showPost=2042#post2042
------------------------------------------------------------------------

Avatar
newton2

2 Posts

24 September 2007 at 5:24am


hi,

i can't seem to get my wysiwyg disabled, i know this is tedious but can anyone please post what files they edited and the exact code they wrote. thanks very much. i hope somebody would be kind enough.