王灵妃与李荣的故事:drupal debug
来源:百度文库 编辑:偶看新闻 时间:2024/05/05 06:51:30
- Community Home
- Getting Involved
- Chat
- Mailing Lists
- Member Directory
- Forum
- Groups & Meetups
How to debug/trace menu calls
Posted by sinasalek on September 27, 2009 at 6:25amHi,
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.
Login or register to post comments Categories: Module Development and Code Questions, Drupal 6.xComments
First, did you clear the
Posted by dougstum on September 28, 2009 at 2:32amFirst, 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']) . '
';
}
}
?>
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!
Doug Stumberger
www.raceonedesign.com
dstumberger --AT-- hotmail --DOT-- com