Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
With Drupal we build many different type of sites and each of these has often different kind of users (Developer, Site Builder, Content Editor, etc.). Each of these users may benefit from having a customized/customizable toolbar menu.
There's already a similar system in place for shortcuts that should make the implementation of this easier to accomplish.
A somehow related issue: #1122816: Assign shortcut set to role
Proposed resolution
Make the toolbar configurable by role. Create a permission to control toolbar menu customization.
Remaining tasks
discuss
User interface changes
none
API changes
none
Comment | File | Size | Author |
---|---|---|---|
#6 | toolbar_150032_6_menu_name_parameter.patch | 2.49 KB | johnv |
#4 | toolbar_150032_4_menu_name_parameter.patch | 2.21 KB | johnv |
#3 | toolbar_150032_2_menu_name_parameter.patch | 1.95 KB | johnv |
Comments
Comment #1
LuxianI'am also looking for this functionality. The main problem is that the Toolbar is working with Management menu, and in order to make it editable for each role we'll have to replicate Management menu. But if we do this, we'll end up having a lot of menus, and every time we install a module, we'll have to manually add new entries from Management menu to all our custom ones. The Shorcut module stores link in its on tables, I don't think that it uses normal menus, that's why it was easier to customize.
The easiest fix will be to use the same menu, but have a separate enable/disable column for each role. This will make things easy (will be easier to filter) before displaying them, but can result in a bloated table when listing menu entries (a lot of enable/disable columns - one for each role). Also the ordering will be globally (the same for all roles), if we want to make that custom, we'll have to figure out a way for allowing the user to sort for each role.
I will be glad to help with the implementation, but we need to clarify how to make this work. I didn't have time to look at the actual implementations. Also, it might be a good idea to sew how Menu pe Role is doing this.
Any suggestion is really appreciated.
Comment #2
johnvYep, it would be nice if we could pass a menu name to Toolbar.
#596010: Move "Administration" link into Account menu and make Toolbar output first level of 'admin' menu is already preparing that, because it uses a proper $menu_name to read the menu items.
For this issue, we might pass a menu_name to function toolbar_get_menu_tree().
Ideally, you can just override the default menu from the pre_render callback function, and add any logic to your custom code:
See attached patch. You should first apply #596010, then all-but-last parts of the patch.
Comment #3
johnvThis time with patch included.
Comment #4
johnvA better version of #3.
Comment #6
johnvWell, third time :-(
first apply #596010, then this patch. They are both for D7. (D8 code has changed significantly - haven't figured out yet how to pass that menu_name).
Comment #6.0
johnvMention of shortcut use case
Comment #7
johnvAnd back to D8..
Comment #10
Wim LeersIn Drupal 8, a
toolbar_configurable_menu
module can usehook_toolbar_alter()
to remove theadministration
tab and reimplement it; allowing per-user or per-role or per-something-else menus.Comment #11
johnvOK, so there seems to be a solution for D8. How about D7?
I think it's not end-of-life, and patch #6 avoids disruptive actions like the Commerce Kickstart menu invokes.
(Yes appying and using it, would meesn a dependency on core >7.28)
(Just a sigh from a small site builder: D7 has been left without love for the last 2 years, since D8-development started. Now that D8 is out, I hope D7-development is not stalled completely...)
Comment #12
johnv