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