6.x core.php hook_translated_menu_link_alter(&$item, $map)
7.x system.api.php 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().


$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


Related topics

1 invocation of hook_translated_menu_link_alter()
_menu_link_translate in includes/menu.inc
This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions.


developer/hooks/core.php, line 403
These are the hooks that are invoked by the Drupal core.


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


mcrittenden’s picture

To change a specific menu item's class:

hook_translated_menu_link_alter(&$item, $map) {
    $item['localized_options']['attributes']['class'] = 'newclass';
aklump’s picture

If you end up with the following error while using this hook. (It appears that it has something to do with breadcrumbs of a parent item when viewing a child item):

Fatal error: Unsupported operand types in ...includes/common.inc on line 1593

Try setting $item['localized_options'] = $item['options'].

The problem comes when the l() function is passed the third argument that is not an array. $item['localized_options'] must be an array.

sarah ravikumar’s picture


Is this hook is still available for drupal 8?