tabs behave odd when access arguments are used

fago - November 18, 2008 - 09:01
Project:Drupal
Version:6.x-dev
Component:menu system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

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:

<?php
 
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:

<?php
 
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.

#1

fago - November 24, 2008 - 12:13
Status:active» by design

ah my silly fault... of course the access arguments need to be available when checking access for the tabs...

 
 

Drupal is a registered trademark of Dries Buytaert.