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.

Customising the CMS /

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

Removing editable fields in child pages


Go to End


3 Posts   3136 Views

Avatar
thepurpleblob

Community Member, 28 Posts

20 February 2011 at 10:15am

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?

Avatar
omarkohl

Community Member, 30 Posts

20 February 2011 at 11:19am

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").

Avatar
thepurpleblob

Community Member, 28 Posts

20 February 2011 at 11:21am

Edited: 20/02/2011 11:22am

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.