Posted by gemini on September 7, 2007 at 7:27pm
Hi everyone!
I'm working on a small module for my company intranet purposes, and one of the functions I need is an additional Menu Tab on specific node type right along with the View and Edit tabs. That particular tab (we'll call it Follow Up) should also have 2 submenu tabs available as well. Should look like this (assuming Follow Up tab is active):
| View | Edit | >Follow Up |
| >Automatic Campaigns | Letters|But here is what I get:
| View | Edit | >Follow Up |
| >Automatic Campaigns | Letters|
| >Automatic Campaigns | Letters|The buttons work correctly and everything is fine beside the fact that they are duplicated.
Here is my hook_menu() code:
<?php
function followup_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/followup',
'title' => t('Follow up settings'),
'description' => t('Select content type for the Follow Up.'),
'callback' => 'drupal_get_form',
'callback arguments' => array('followup_admin_settings'),
'access' => user_access('administer site configuration')
);
}else
{
$types_to_followup = variable_get('followup_nodetypes', array('leads'));
if (!$may_cache) {
if(in_array($node->type, $types_to_followup)){
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if ($node->type == 'leads') {
$items[] = array('path' => 'node/'. arg(1) .'/followup',
'title' => t('Follow Up'),
'callback' => 'followup_tab_page1',
'callback arguments' => arg(1),
'access' => node_access('update', $node),
'type' => MENU_LOCAL_TASK,
);
$items[] = array('path' => 'node/'. arg(1) .'/followup/campaign',
'title' => t('Automatic Campaigns'),
//'callback' => 'followup_tab_page1',
//'callback arguments' => arg(1),
'access' => node_access('update', $node),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array('path' => 'node/'. arg(1) .'/followup/letters',
'title' => t('Letters'),
'callback' => 'followup_tab_page2',
'callback arguments' => arg(1),
'access' => node_access('update', $node),
'type' => MENU_LOCAL_TASK,
);
}
}
}
}
}
return $items;
}
?>The first condition is for the Admin Settings and the second one for the node.
I appreciate any help!
Thanks!