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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Luxian’s picture

I'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.

johnv’s picture

Yep, 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:

function MYMODULE_page_build(&$page) {
  if (isset($page['page_top']['toolbar'])) {
//    $page['page_top']['toolbar']['#pre_render'] = array('toolbar_pre_render');
    $page['page_top']['toolbar']['menu_name'] = 'main-menu';
  }
}

See attached patch. You should first apply #596010, then all-but-last parts of the patch.

johnv’s picture

Status: Active » Needs review
FileSize
1.95 KB

This time with patch included.

johnv’s picture

A better version of #3.

Status: Needs review » Needs work

The last submitted patch, toolbar_150032_4_menu_name_parameter.patch, failed testing.

johnv’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs work » Needs review
FileSize
2.49 KB

Well, 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).

johnv’s picture

Issue summary: View changes

Mention of shortcut use case

johnv’s picture

Status: Needs work » Needs review

And back to D8..

Status: Needs review » Needs work

The last submitted patch, toolbar_150032_6_menu_name_parameter.patch, failed testing.

Status: Needs review » Needs work
Wim Leers’s picture

Version: 7.x-dev » 8.0.x-dev
Issue summary: View changes
Status: Needs work » Closed (works as designed)

In Drupal 8, a toolbar_configurable_menu module can use hook_toolbar_alter() to remove the administration tab and reimplement it; allowing per-user or per-role or per-something-else menus.

johnv’s picture

Title: Make the toolbar menu configurable per role/per user » Make the toolbar menu configurable per role/per user (D7)
Version: 8.0.x-dev » 7.x-dev

OK, 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...)