What is the best way to resort and hide (some) items on the left-hand bar in CMS?

Silverstripe Version:

SS4

Question:

I would like to re-order the items on the left-hand side of the CMS (the one with Pages, Files, Security). What is the easiest way to do this? Also, I want to hide “Campaigns”.

Lastly, has anyone looked at the Group CMS Menu Items for four?

https://addons.silverstripe.org/add-ons/ryanpotter/silverstripe-cms-theme

will give you some grouped menu code, along with some nice customisations.

The sort order of those items are determined via a static called $menu_priority, and you can override them in your mysite.yml, for e.g.:

SilverStripe\CampaignAdmin\CampaignAdmin:
  menu_priority: -2

The lower the number (negatives allowed) the lower it appears, you may have to experiment with the number to use.

Can’t help you with hiding it, am interested to know how to too.

awesome! thank you for all your ideas.:star_struck::sparkles::sparkles:

In terms of hiding menu items, the simplest way to do so is with the permissions system of the CMS. People in the ‘Administrators’ group have access to everything, but you can set up a different group for general admin use and uncheck the ‘access to campaigns’ permission on that group.

1 Like

To remove a menu item you can use
SilverStripe\Admin\CMSMenu::remove_menu_class('CampaignAdmin');
in your _config.php file.

To remove the whole campaigns module you should be able to just not include it in your composer.json, or if you include a recipe in your composer file, you can use
“replace”: {
“silverstripe/campaign-admin”: “*”
},
to tell composer you handle this dependency yourself and to not install it.

4 Likes

Just a follow-up on this, in SS4, you’ll probably need the fully qualified class name in the config line, eg:

use SilverStripe\CampaignAdmin\CampaignAdmin;
use SilverStripe\Admin\CMSMenu;

CMSMenu::remove_menu_class(CampaignAdmin::class);

Ahhhh. That is awesome ! Thank you Florian

Here’s the 4 “hide menu item pants” I frequent…

use SilverStripe\Reports\ReportAdmin;
use SilverStripe\Admin\SecurityAdmin;
use SilverStripe\VersionedAdmin\ArchiveAdmin;
use SilverStripe\CampaignAdmin\CampaignAdmin;

CMSMenu::remove_menu_class(ReportAdmin::class);
CMSMenu::remove_menu_class(SecurityAdmin::class);
CMSMenu::remove_menu_class(ArchiveAdmin::class);
CMSMenu::remove_menu_class(CampaignAdmin::class);
1 Like