Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Is there an elegant way to turn off comments globally

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2176 Views
  • robinp
    Avatar
    Community Member
    33 Posts

    Is there an elegant way to turn off comments globally Link to this post

    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

  • Anatol
    Avatar
    126 Posts

    Re: Is there an elegant way to turn off comments globally Link to this post

    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

  • robinp
    Avatar
    Community Member
    33 Posts

    Re: Is there an elegant way to turn off comments globally Link to this post

    Hi Anatol,

    Great thank you

    Cheers

    Robin

  • ianski
    Avatar
    Community Member
    2 Posts

    Re: Is there an elegant way to turn off comments globally Link to this post

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

    CMSMenu::remove_menu_item('CommentAdmin');

    2176 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.