[development] problem with hook_menu
Hans Langouche
hans.langouche at gmail.com
Tue Jun 30 08:38:17 UTC 2009
Hi,
I'm running into a problem with the menu system. I have a 'project'
content type that has a couple of child links to show either some cck
field of that node or some embedded views with related content (but I
think what happens on those child paths is not relevant). The problem I
have is that these child paths often show the content of the parent
(node) path instead of the content it's supposed to show (this will go
away after clearing cache, but comes back again).
Below is how I add the paths to the system, nodeapi then also adds
aliases for each of those links (based on the alias of the parent
link). Note that this problem also occurs when I visit the link with
the real path (e.g. node/x/more, so I guess the alias system is also not
the cause).
Originally I didn't add in the file and file path (as the hook_menu call
is in the same module as the page callback's), I added it in to try to
solve this cache (?) problem.
Any suggestions or tips are appreciated :-)
Hans
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(3)) {
$_node = node_load(arg(1));
if ($_node->type == 'project') {
$items = array();
$items['node/%node/more'] = array(
'title callback' => 'projecttabs_title',
'title arguments' => array(1, t('more')),
'page callback' => 'projecttabs_tabs_more',
'page arguments' => array(1),
'file' => 'projecttabs.module',
'file path' => drupal_get_path('module', 'projecttabs'),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
More information about the development
mailing list