Reputation: 11
I'm writing a Drupal 7 module. Therefore, parts of my implementation of hook_menu() look like this:
$items['admin/mymodule/a'] = array(
'title' => 'A',
'page callback' => 'mymodule_a',
'access arguments' => array('administer mymodule'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
$items['admin/mymodule/a/%id/edit'] = array(
'title' => 'Edit',
'page callback' => 'mymodule_edit',
'access arguments' => array('administer mymodule'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
$items['admin/mymodule/a/%id/details'] = array(
'title' => 'Details',
'page callback' => 'mymodule_details',
'access arguments' => array('administer mymodule'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
Now what I'm trying to achieve is to hide links from the page titled 'A' to the secondary tabs, still having links among those secondary tabs, i.e. when accessing admin/mymodule/a, there should be no links to secondary tabs shown, while for admin/mymodule/a/42/edit there should be links added to both the .../42/edit and .../42/details page. I guess this should easily be achievable, but I can't figure out how... Thanks for your suggestions!
Upvotes: 1
Views: 1174
Reputation: 807
I'm new to drupal myself, but I think you can use the following hook:
hook_menu_alter(&$items)
// http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu_alter/7
to alter the 'type' of the 2 last pages to MENU_CALLBACK (which will then hide the tabs for these pages)
EDIT (after reading your reply):
$items['pages/render-array'] = array(
'title' => 'Render array',
'description' => 'Menu system example using a render array.',
'page callback' => 'pages_render_array',
'access arguments' => array('access content'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
$items['pages/render-array/tab1'] = array(
'type' => MENU_DEFAULT_LOCAL_TASK,
'title' => 'Tab 1',
);
$items['pages/render-array/tab2'] = array(
'title' => 'Tab 2',
'description' => 'Demonstrating secondary tabs.',
'page callback' => 'pages_render_array',
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
this is code for a page with 2 subtabs, I think you're able to put a condition on the 'hook_menu_alter' (= when in page 'A') to alter the other 2 pages (or something like that..?)
really sorry if this doesn't help either, just trying to brainstorm overhere :D (first week of drupal)
Upvotes: 0