By yookoala on
I'm currently writing a module and I want to make a stand alone admin menu item.
I wrote my hook_menu like this:
function foobar_menu() {
$items['admin/foobar'] = array(
'title' => 'Foobar Admin',
'description' => 'Foobar related administration tasks',
'page callback' => 'foobar_admin',
'access callback' => 'user_access',
'access arguments' => array('administer foobar'),
'description' => 'View and administer all the foobar.',
'file' => 'includes/admin.inc.php',
'type' => MENU_NORMAL_ITEM,
);
$items['admin/foobar/child'] = array(
'title' => 'Foobar Child Task',
'description' => 'Child administration task',
'page callback' => 'mailnews_admin_child',
'access callback' => 'user_access',
'access arguments' => array('administer foobar'),
'description' => 'View and administer all the foobar child.',
'file' => 'includes/admin.inc.php',
'type' => MENU_LOCAL_TASK,
);
return $items;
}
I expected the "Foobar Child Task" to appear, as a tab, on the "Foobar Admin" page, But the task didn't show up. Did I got anything wrong? Please help.
Thanks.
Koala Yeung
Comments
The tab page needs the same
The tab page needs the same root path as the "main" page it relates to.
Root page
In this case, I expect admin/foobar would be the "main" page of admin/foobar/child. But that is not the result.
For the tabs to be rendered,
For the tabs to be rendered, you need a minimum of two tabs, and one of them has to be of type MENU_DEFAULT_LOCAL_TASK. You only have one, and this is why your tab is not rendering. Add this:
Contact me to contract me for D7 -> D10/11 migrations.
Fixed.
Problem fixed. Thanks!