I want to alter specific menu items with a hook.

(In my theme's template.php but since it involves hooks I thought this would be more appropriate)

I know the menu, depth, location and menu item id ahead of time - all I need is to change them (In one I need to change the text, in another I need to change the link, both require queries per user)

Using hook_menu_item_link() and hook_menu_alter() don't seem to work.

How do I change these specific menu items?

Comments

jaypan’s picture

hook_menu_alter().

Contact me to contract me for D7 -> D10/11 migrations.

rstaylor’s picture

This sounds like it may be a case for overriding
theme_menu_link ( http://api.drupal.org/api/drupal/includes%21menu.inc/function/theme_menu... )
to change the display output rather than altering the actual data of the menu item (router and access control).

jaypan’s picture

I guess it depends on whether he wants to change the displayed text (hook_menu_alter()) or the outputted HTML (theme_menu_link()).

Contact me to contract me for D7 -> D10/11 migrations.

jnvsor’s picture

This worked perfectly - thanks!

chetan-singhal’s picture

hook_menu_alter
clear drupal cache

chetan

DeNelo’s picture

Maybe you can use the module Menu Token. With this module you can add any token to menu titles. Very neat.