Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » I don't want WYSIWYG

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

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

Page: 1
Go to End
Author Topic: 3848 Views
  • tomasulej
    Avatar
    Community Member
    2 Posts

    I don't want WYSIWYG Link to this post

    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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: I don't want WYSIWYG Link to this post

    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!

  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Re: I don't want WYSIWYG Link to this post

    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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: I don't want WYSIWYG Link to this post

    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?"

  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Re: I don't want WYSIWYG Link to this post

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

  • newton2
    Avatar
    2 Posts

    Re: I don't want WYSIWYG Link to this post

    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.

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