How to create secondary local tasks or secondary tabs, also called sub tab (second level) menu items.
It was not clear to me why it was necessary to create a MENU_DEFAULT_LOCAL_TASK in every tab level. In order to tell drupal's menu system to show primary and secondary local tasks, there is a need to create a default local task every time. The default local task points to the same page as the parent item but has a path longer by one element.
Parent path:
'admin'
Default primary local task path:
'admin/home'
Default secondary local task path:
'admin/home/home'
All three menu items go to 'admin' and all three show 'admin' on the address bar. Both local tasks can share the same page callbacks.
The code inside your hook_menu() would look something like this.
$items['cart/admin'] = array(
'title' => 'Cart Administration',
'page callback' => 'cart_admin_home_page',
'access arguments' => array('access cart admin pages'),
);
$items['cart/admin/home'] = array(
'title' => 'Admin\'s Home',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['cart/admin/home/home'] = array(
'title' => 'Admin\'s Home',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
Check out the following link to understand how to set up secondary tabs or secondary local tasks. This took me several hours to find and understand.
Post new comment