Improve The Drupal 8 Admin Menu for Content Creators

The Drupal admin interface needs to keep a lot of people happy. The admin interface is often used by everyone from very experienced users to complete beginners.
One of our members asked if it was possible to create a custom menu for their content creators. They wanted one single place for Drupal beginners to find all the links they needed.
In this tutorial, we’ll show you how to do that and also create a faster, more usable admin menu.
Step #1. Publish the menu for content creators
- Download the modules Admin Toolbar , Toolbar Anti-flicker and Toolbar Menu
- Install and enable the modules.
- You will have to configure the Toolbar menu module
Now we need to add a custom menu. Go to:
- Go to Structure > Menus > Add Menu.
I added a menu called OSTraining Menu. It would be best to make the menu name as short as possible. If the user’s browser window is too small, the custom menus do not display.
Next, we need to add it to the menu bar. Go to:
- Go to Configuration > Toolbar Menu.
- Enable you menu, which in my example is “OSTraining Menu”.
- Click “Save configuration”.
Now we have our custom menu showing in the admin menu, as in the image below:
Step #2. Create the menu links
Currently we have an empty menu, so let’s add some links for our users.
- Go to People > Roles > Add
- Create the “Role”. In this example, I’m creating a “OSTraining Members” role.
Lets add create article to the menu so you can get an idea how it works. Go to:
- Structure > Menus.
- Next to OSTraining Menu, select “Edit menu”.
- Add link
All the links added here will be sub Menus of our custom menu block. The image below shows a link that will allow members to add an article:
You will need to make sure the permissions are correct, so that your users can access the custom menu. Go to:
- People > Permissions.
Figuring out which permissions you need can often be troublesome, so to save time I am going to list the permissions you will require. Check the following permissions :
- Toolbar (grants access to the admin toolbar)
- Toolbar Menu (grants access to the custom menus)
- View the OSTraining Menu menu in the toolbar (grants access to the custom menu we created)
- Article: Create new content (This will allow the user to make articles)
Once you’ve finished this process, your users will see the “OSTraining Menu” and then the “Add article” link underneath. You can use the combination of custom menus and permissions to configure entire groups of users to perform specific roles for the website.
Thanks for the article and solution.
(Unfortunately, something like this needs 3 extra modules ;( )
D8 is ever evolving those modules could all be put into core in a few months.
I actually wanted the same thing, but I was happy to code it myself instead of using several modules.
I started by implementing hook_toolbar_alter(), and set:
$items[‘administration’][‘tray’][‘toolbar_administration’][‘#pre_render’][0]
= ‘mymodule_prerender_toolbar_administration_tray’;
Then my mymodule_prerender_toolbar_administration_tray() function was basically a custom version of admin_toolbar_prerender_toolbar_administration_tray(), in which I made sure to set:
$tree = $menu_tree->load(‘owner-menu’, $parameters);
For me, since I wanted the menu to show for certain roles, I fetched the user:
$currentUser = \Drupal::currentUser();
Then did a check for the user role:
$currentUser->getRoles()
Thanks for the tip on Toolbar Menu module, thats what I was looking for! I also use [url=https://www.drupal.org/project/toolbar_themes]https://www.drupal.org/proj…[/url] to make it all smaller and looks better imo, cheers.
Hello
I want to display one menu i.e “Menu1” for one user role and “Menu 2” for another user role. When I am adding in tools, it shows all custom menus in it.
Thanks
Hiral
Hi Hiral,
I would create separate menus for each of those.
And then using permissions set who has access to each.
Thanks,
Daniel
ok. thank you!