I just tried to make some tabs below /user/% for the content profile module and failed. The tabs only appeared when I clicked on user/%/track/navigation from the statistics module or on profile category of the core profile module - else they were not visible!
So I played around a bit and compared my code to working code from other modules and noticed that the distinction seems to be only the access callback or access arguments. As soon as the access callback is not user_access or I let loaded arguments pass to the callback - the tabs behave wrong as described.
Working code:
foreach (content_profile_get_types('names', 'edit_link_sub') as $type => $type_name) {
$items['user/%user/profile/'. $type] = array(
'title' => drupal_ucfirst($type_name),
'page callback' => 'content_profile_page_edit',
'page arguments' => array(3, 1),
'access callback' => 'content_profile_page_access',
'access arguments' => array('bla'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
}
Not working code:
foreach (content_profile_get_types('names', 'edit_link_sub') as $type => $type_name) {
$items['user/%user/profile/'. $type] = array(
'title' => drupal_ucfirst($type_name),
'page callback' => 'content_profile_page_edit',
'page arguments' => array(3, 1),
'access callback' => 'content_profile_page_access',
'access arguments' => array(3, 1),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
}
Replacing 'content_profile_page_edit' with 'user_access' in the not working example, let's it work too.
Comments
Comment #1
fagoah my silly fault... of course the access arguments need to be available when checking access for the tabs...