Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By glueckskind on
Hi,
I have 2 node types: typea and typeb. I want to show menu tabs for typea, but not for typeb.
function mymodule_menu() {
$items = array();
$items['node/%node/tab1'] = array(
'title' => 'tab1',
'page callback' => 'theme_function_tab1',
'page arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
$items['node/%node/tab2'] = array(
'title' => 'tab2',
'page callback' => 'theme_function_tab2',
'page arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
The problem is, that the tabs are shown on every node. How can I cell Drupal not to show the tabs on every node without manipulation the node.tpl.php?
Thanks
Comments
You can base the $items on
You can base the $items on the URL ($_GET['q'] and arg()). Say that you want to display tab1 only when the node is a multiply of 2 and your url si http://www.mydomain.com/node/1/
Where:
arg(0) = node
arg(1) = 1
Obviously you lost the possibility to cache the $items.
M.
PS: this code is not tested but it's a start point.
Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it
Try this: <?php function
Try this:
Be sure to rebuild the menu to test.
--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.onnetworks.com
--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.zivtech.com
Thanks for your responses
Thanks for your responses but this works only for Drupal 5 and not for Drupal 6
You mean the other way
You mean the other way around. menu_get_object() should result in a fatal error in drupal 5.
--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.onnetworks.com
--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.zivtech.com
Had the same question a while ago ... now solved
The solution is explained here: http://drupal.org/node/218692