Rearrange Drupal admin menu items for usability purposes

13 Sep 2011

Joris Snoek
Digital Consultant
+31 (0)20 - 261 14 99

Ever wanted to get a nice and clean admin menu for your Drupal content managers. So the menu becomes more clear and usable?

So, for example, show a direct link to 'Primary links' menu under 'Content management'.

I already gave another Blog post about this, where I explain how to forbid access to certain individual menu items.
See Show only the relevant admin menu items to your content manager

Over here a kick start, we experience a lot satisfaction with our customers as Drupal becomes a lot more usable.
The content managers only see menu items they use, where we want them to it.

Beneath I explain, how to rearrange your menu items, with help of a short simple piece of code. It is a little 'work around' but works just fine and is safe. Do you know a better way, hit me on Twitter right away!

The module code

/**
* Implementation of hook_menu().
* Build and redirect menu links for content management usability purposes
*/
function YOURMODULE_menu () {

   $items['admin/content/primairylinks'] = array(
       'title' => t('Primairy links'),
       'weight' => -10,
       'page callback' => _YOURMODULE_goto_primarylinks,
       'access arguments' => array('administer content'),
       'type' => MENU_DEFAULT_LOCAL_TASK,
     );

   return $items;
}

/**
* Custom function
* Redirects user on click on defined menu item above in hook_menu
*/
function _YOURMODULE_goto_primarylinks (){
  drupal_goto('admin/build/menu-customize/primary-links');
}

The set up

Well..
1) Create a new menu item with help of hook_menu().
In this example you got to have the permission "administer content" to view the defined menu item.
2) When the user clicks on the item, the custom function will redirect the user to correct page
3) That's it.

Access control

I want to emphasise that this piece will NOT (re)build access restrictions to any menu items.
All set permissions stay in tact, as user will be redirected to the original menu hook (menu item).
More information on access control and the Drupal menu system: http://drupal.org/node/109157

Feedback, Questions about menu items, rearrange them or access control?

Or maybe you know a nice module that does the trick...
Please hit me on Twitter for all your feedback, and any other issue!

Comments

Nóg meer
kennis nodig?

Check ons ons blog archief >