By thx538 on
I've read the new menu documentation for D6 and implemented a hook_menu with the following code, which create a tab on each node .... fine.
$items['node/%node/details'] = array(
'title' => 'Details',
'page callback' => 'node_mydetails',
'page arguments' => array('Details',1),
'access callback' => 'user_access',
'access arguments' => array('access content'),
'type' => MENU_LOCAL_TASK,
);
The problem is that I would like this "Details" tab to appear only on some content-type.
It sems to me that it's not possible given the new menu implementation in D6 and hook_menu being called only
rarely - for example when modules are enabled
.
Thanks for your support .... this a must have for me.
Comments
how about you use this, I
how about you use this, I haven't tested it but the idea should work.
give it a try and set me know. Good luck =)
Does not work
"my_node_load" is only invoked for "my_node" content-type btw
its just an example, all it
its just an example, all it is a custom loader function which is called when the menu is being constructed by drupal. Call it whatever you want, just make a function which takes an integer as an argument, load the node and check its type. If the function returns a value (ie. the node we want the menu for) then the link is used etc, if not then the menu is not shown or the page not found.
so intead make the function name my_node_menu_load and then in the menu array key use node/%my_node_menu_load/details. Remember to replace my_node with your module name or whatever.
I see ....
It worked, except that the custom loader has to explicitly return FALSE if the test is unsuccessful.
Many thanks for your help ....
many thanks for this
many thanks for this solution.
Thanks
Good solution - Thanks
I'm wondering why a similar
I'm wondering why a similar solution wasn't implemented via an access callback function as this seems a more appropriate way to solve the problem ( although I haven't tested it ) ?
This works for me and seems
This works for me and seems mildly more fit for purpose :