Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Removing editable fields in child pages

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

Page: 1
Go to End
Author Topic: 1463 Views
  • thepurpleblob
    Avatar
    Community Member
    28 Posts

    Removing editable fields in child pages Link to this post

    If I inherit a new page type from the default Page, I get a free 'page content' area (and edit box in the cms view). What if I don't need it (i.e., the page only has static template content)? Is there some way to remove the content for that one page type?

  • omarkohl
    Avatar
    Community Member
    30 Posts

    Re: Removing editable fields in child pages Link to this post

    I haven't tested it but this should do it (inside your child Page class):

    function getCMSFields() {
    $fields = parent::getCMSFields();
       $fields->removeFieldFromTab("Root.Content", "Main");
    return $fields;
    }

    If you want to remove more specific parts instead of the whole Main tab you can use the same function with first parameter "Root.Content.Main" and second parameter the name of the element you want to remove (e.g. "Content").

  • thepurpleblob
    Avatar
    Community Member
    28 Posts

    Re: Removing editable fields in child pages Link to this post

    Thanks... just as you replied (with some source digging) I came up with...

    function getCMSFields() {
    $fields = parent::getCMSFields();

    // we don't want the Content editor for this page type
    $fields->removeFieldFromTab('Root.Content.Main', 'Content');
    return $fields;
    }

    in the Model class. Not sure if this is what you had in mind. I was inspired by the example to *add* fields in the tutorial.

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