Reputation: 2760
I have a NewsholderPage and NewsPage. NewsPages are subpages of NewsholderPage. I need users of a certain group to be able to create NewsPages, but not to be able to edit the NewsholderPage. If I put the following code into the NewsholderPage...
public function canEdit($member = null){
if(permission::check('SUPERUSER')){
return true;
}
return false;
}
... then a not-admin cannot edit the NewsholderPage but also gets a "forbidden" message, when he is trying to create a NewsPage as child of the NewsholderPage. What is the best way to allow the creation of subpages, while not allowing to edit the parent page?
Upvotes: 1
Views: 179
Reputation:
You'll want to override the canAddChildren
method on NewsholderPage to return something other than the default (which is simply $this->canEdit()
). To get the default behaviour back, you can use something like:
public function canAddChildren($member = null) {
// Call SiteTree::canEdit rather than NewsholderPage::canEdit
return parent::canEdit($member);
}
Upvotes: 3