Hi,
Is there an elegant simple way to turn off comments in all pages and remove the comments tab from the CMS ?
Thank you
Cheers
Robin
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Hi,
Is there an elegant simple way to turn off comments in all pages and remove the comments tab from the CMS ?
Thank you
Cheers
Robin
Hi Robin,
Add a few lines (in green) to /mysite/code/Page.php to the Page class:
class Page extends SiteTree {
public static $db = array(
);
public static $has_one = array(
);
static $defaults = array(
'ProvideComments' => false
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Behaviour","ProvideComments");
return $fields;
}
}
To remove the comments tab this should work (add this to your /mysite/_config.php file):
Object::addStaticVars('LeftAndMain', array(
'removed_menu_items' => array(
'comments'
),
));
I read somewhere that Silverstripe 2.3 uses
LeftAndMain::remove_menu_item('comments');
CMSMenu::remove_menu_item()
Not sure which one works for your version of Silverstripe.
Cheers!
Anatol
Hi Anatol,
Great thank you :-)
Cheers
Robin
Silverstripe 2.3.3...to remove from the main tabs...
CMSMenu::remove_menu_item('CommentAdmin');