Hi,
I'm developing a module and have some strange problems with hook_menu. i copied the code from a working module but it does not work exactly like the original menu. I want to know how can i trace menu calls of a specific url from the beginning and know what calculating it does which results in a wrong page, in order to know what's exactly wrong with my implementation.

I'm familiar with devel, and i already searched forum but i couldn't find anything useful.

Thanks.

Comments

Anonymous’s picture

First, did you clear the cache or rebuild the menus after tinkering with hook_menu? You need to do that in order to see the effect of your changes. Also, you might provide more details on your problem--what is the menu item that you think is not working?

Also, you might try something like this:

function YOURMODULE_menu_alter(&$callbacks) {
  //  DEBUGGING OUTPUT.
  foreach ($callbacks as $path => $options) {
    $access = $options['access callback'] ? $options['access callback'] : 'user_access';
    $page = $options['page callback'] ? $options['page callback'] : 'no page callback';
    echo $path . " | ". $page . " | " . $access . " | " . implode(', ', $options['access arguments']) . '<br />';
  }
}

once you've defined this in a module, you rebuild your menus or cache. I use this to get a dump of the entire menu structure. This should show you exactly which 'page callback' function is being executed for a given path, provided that there are not downstream modules that use menu_alter to change the structure.

Hope that helps!

tbisciglia’s picture

Doug - I know this post is 6 years old now, but it totally saved me on a project! There was a menu callback I could not track down for the life of me, and thanks to your trick, I found it hiding in a custom module I didn't even know existed due to its lousy naming convention. So glad you wrote this! I'll keep it for posterity.