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

silverstripe-4
Tags: #<Tag:0x00007f08439d3ee0>

#1

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?


#2

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

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


#4

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


#3

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.


#5

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.


#6

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.


#8

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


#7

Ahhhh. That is awesome ! Thank you Florian