Last updated March 8, 2013. Created by gpk on September 12, 2007.
Edited by cheekdotcom, Wolfflow, pwolanin. Log in to edit this page.
The Drupal 6.x menu system introduces two new _alter hooks for changing the items being saved to the {menu_router} or {menu_links} tables.
hook_menu_alter
hook_menu_alter() is invoked via drupal_alter() as part of menu_router_build() before the menu items (which define all valid Drupal paths) are saved to the {menu_router} table.
A Drupal path is the string such as 'node' in example.com/?q=node, or assuming clean URLs, example.com/node. Each path in {menu_router} is unique. For convenience, a menu link (see below) corresponding to the path is usually added to the navigation menu.
This alter hook might be used, for example, to change the access callback that determines who can view the corresponding page, or to change any other property declared by a module in hook_menu.
hook_menu_link_alter
hook_menu_link_alter() is invoked via drupal_alter() as a part of menu_link_save() before a link (an item visible in a menu like the Navigation menu) is saved to the {menu_links} table. Links are hierarchical, and there may be many links to the same path. This hook might be used, for example, to add a particular CSS class to some links, or to append a string to the link text.
Comments
Links to alter must be untouched or reseted prior to alter them
hook_menu_link_alter() will not work on links touched by administrator at ...admin/build/menu-customize/navigation.
Those links must be untouched or reseted in order for hook_menu_link_alter() to work.
If the link was touched then in drupal db , table: menu_links -> column: customized that link will have a value of 1.
Else value is 0.
Boy, an example would sure help.
I'm looking for a very easy way to alter a menu link when a user is logged in. These words are very hard to convey implementation without an example.
Hakuna Matata