hook_translated_menu_link_alter

Versions
6 – 7
hook_translated_menu_link_alter(&$item, $map)

Alter a menu link after it's translated, but before it's rendered.

This hook may be used, for example, to add a page-specific query string. For performance reasons, only links that have $item['options']['alter'] == TRUE will be passed into this hook. The $item['options']['alter'] flag should generally be set using hook_menu_link_alter().

Parameters

$item Associative array defining a menu link after _menu_link_translate()

$map Associative array containing the menu $map (path parts and/or objects).

Return value

None.

Related topics

Code

developer/hooks/core.php, line 364

<?php
function hook_translated_menu_link_alter(&$item, $map) {
  if ($item['href'] == 'devel/cache/clear') {
    $item['localized_options']['query'] = drupal_get_destination();
  }
}
?>

How to change a menu item class from a module

mcrittenden - Tue, 2009-10-20 16:21

To change a specific menu item's class:

hook_translated_menu_link_alter(&$item, $map) {
    $item['localized_options']['attributes']['class'] = 'newclass';
}

Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.