Skip to main content
1 of 6
Ashlar
  • 5.1k
  • 6
  • 35
  • 56

Drupal Coding D7 - Menus - My hook_menu_alter & page callback doesn't get triggered.

This question relates to the another question

I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback.

function material_menu_taxonomy_page_callback($term) {
    dsm('Entered material menu callback');
}
function material_menu_menu_alter () {

  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'material_menu_taxonomy_page_callback'; 
}

I placed a code line dsm("Altering");in the callback to see where in the process the callback is being called, but it never shows up.

I am fairly certain that I have the code correct.

  • The hook has the name of the custom module.
  • The callback name is correct.
  • the callback is in the same file as the hook
  • I have turned the module off and then on so that I can be sure that Drupal knows about mymodule_menu_alter
  • And I have flushed the caches.

My assumption is that `mymodule_menu_alter' should change the callback in the menu item array and that the callback will be called each time the menu item is selected. That suggests that my dsm message should display at the top of the page requested by the menu.

All suggestions on what might be causing this problem are welcome!

Ashlar
  • 5.1k
  • 6
  • 35
  • 56