
There 2 methods to add a menu in Drupal, hookmenu or hookmenu_alert
We can define a menu like this:
$items['user/%user/facebook'] = array(
'title' => 'Facebook',
'description' => 'Facebook Profile',
'page callback' => 'facebook_user_settings',
'file' => 'facebook.pages.inc',
'page arguments' => array(1),
'access callback' => 'facebook_user_access', //access arguments don't support multiple arguments, so create our access handler
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
Because the menu type is MENULOCALTASK, this will add a new tab “Facebook” right after the “edit” tab.
But how to add the “facebook” tab in secondary level, after “Account”, just do as the “Linkedin” tab?
The following code is NOT right:
$items['user/%user/edit/facebook'] = array(
'title' => 'Facebook',
'description' => 'Facebook Profile',
'page callback' => 'facebook_user_settings',
'file' => 'facebook.pages.inc',
'page arguments' => array(1),
'access callback' => 'facebook_user_access', //access arguments don't support multiple arguments, so create our access handler
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
);
This will lead some errors. You should do as the following steps, (Linkedin codes):
Step 1, show a tab menu after “Account”:
function linkedin_user_categories() {
return array(
array(
'name' => 'linkedin',
'title' => 'Linkedin',
'weight' => 3,
),
);
}
Step 2, define the menu callback functions:
function linkedin_menu_alter(&$callbacks) {
$callbacks['user/%user_category/edit/linkedin']['page callback'] = 'linkedin_user_settings';
$callbacks['user/%user_category/edit/linkedin']['module'] = 'linkedin';
$callbacks['user/%user_category/edit/linkedin']['page arguments'] = array(1);
$callbacks['user/%user_category/edit/linkedin']['file'] = 'linkedin.pages.inc';
}
There is no document about hookusercategories for Drupal 7, so this article shows How to use it.
Hope to help you.