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

Is there an elegant way to turn off comments globally


Go to End


4 Posts   3261 Views

Avatar
robinp

Community Member, 33 Posts

24 February 2009 at 11:52am

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

Avatar
Anatol

126 Posts

6 March 2009 at 4:56pm

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');

or
CMSMenu::remove_menu_item()

Not sure which one works for your version of Silverstripe.

Cheers!
Anatol

Avatar
robinp

Community Member, 33 Posts

6 March 2009 at 5:45pm

Hi Anatol,

Great thank you :-)

Cheers

Robin

Avatar
ianski

Community Member, 2 Posts

14 October 2009 at 12:13pm

Silverstripe 2.3.3...to remove from the main tabs...

CMSMenu::remove_menu_item('CommentAdmin');