Hi,
a couple of questions on module development which I can't get my head around...
I'm adding in a couple of administration features for my module, so I currently have the following items added...
function mymodule_menu() {
$items = array();
$items['admin/content/option1'] = array(
'title' => 'Option 1',
'description' => 'Description for option 1.',
'page callback' => 'mymodule_option1',
'access arguments' => array('administer mymodule'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/content/option2'] = array(
'title' => 'Option 2',
'description' => "Description for option 2.",
'page callback' => 'mymodule_option2',
'access arguments' => array('administer mymodule'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
This of course makes the items appear under Content Management. What would I have to add to make them appear under their own menu grouping, i.e. Administration -> MyModule -> Option 1 and Administration -> MyModule -> Option 2.
Also as the owner of the site doesn't need any other admin functions I have removed all the permissions to such from their role, however the main menu groups within Administration still appear ( Site Building, Site Configuration, User Management and Help ). I tried the following to remove these items...
function mymodule_menu_alter(&$items) {
global $user ;
if ( $user->uid && in_array('owner', $user->roles ){
unset( $items['admin/build'] );
unset( $items['admin/settings'] );
unset( $items['admin/user'] );
unset( $items['admin/help'] );
}
}
but the menu options still appear when logging in as a test owner. I looked at Pro Dupal Development but the technique mentioned there didn't seem to work either. So what's the best way to remove menu items ?
Thanks,
Keith
Comments
Update
Seems I am using the wrong hook for the second part of my query... an investigation via menu_per_role indicates I should be using hook_translated_menu_link_alter instead.
Anyone any ideas about the first though ?
Thanks,
KH