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.

Customising the CMS

Removing editable fields in child pages


Reply

3 Posts   1578 Views

Avatar
thepurpleblob

20 February 2011 at 10:15am Community Member, 28 Posts

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

20 February 2011 at 11:19am Community Member, 30 Posts

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

20 February 2011 at 11:21am (Last edited: 20 February 2011 11:22am), Community Member, 28 Posts

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.