1
votes

Another best-practice question here. When tweaking the CMS, for example deleting the Help button as follows:

class HideButton extends LeftAndMainExtension
 {
  public function init()
   {
     parent::init();
     CMSMenu::remove_menu_item('Help');
   }
 }

Where is the best place to store this kind of code? I was assumed that would be the mysite folder, but I had my doubts since it's debatable if this code actually relates to the "site" rather than the framework.

1

1 Answers

3
votes

It always depends on the situation... but in this case it sounds like you are wondering how you could reuse this for each new site you make... which means it should be placed in a module.

Here is where many modules for silverstripe are searchable... You might even find this code in one of them... developers often have "boilerplate" or "utilities" that contain things like this. I hope you'll find useful ideas for your project as well as many examples to learn from...

http://addons.silverstripe.org/

Here is some very comprehensive documentation on creating modules...

https://docs.silverstripe.org/en/3.4/developer_guides/extending/modules/

One last note would be to include these modules with composer - you may have installed with this but if not it is worth learning and using it before modules because it makes the use (install, upgrade, etc) much much easier.