Disappearing MENU_LOCAL_TASK items and different Wildcard Loader Arguments

Ryan Palmer - January 8, 2009 - 20:54
Project:Drupal
Version:6.11
Component:menu system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

I have a client who has requested a dedicated form for managing the user's picture be made available from a local task within the user/#uid/edit context. The following menu item does this for the most part:

Menu item code:

<?php
  $items
['user/%user/edit/picture'] = array(
   
'title' => 'Picture',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('tpp_picture_form', 1),
   
'access callback' => 'user_edit_access',
   
'access arguments' => array(1),
   
'type' => MENU_LOCAL_TASK,
  );
?>

... but not when visiting the actual "Picture" page. When on the "Picture" page, no local tasks are shown.

Please see account.jpg, athelete.jpg and picture.jpg below for examples if the local tasks showing and not showing.

Many other local tasks successfully appear on different pages. The only difference between the "Pictures" menu item and the rest is the Wildcard Loader Argument used: Pictures uses user_load() whereas the others use user_category_load(). Could this be where the issue is coming from?

AttachmentSizeStatusTest resultOperations
account.jpg14.64 KBIgnoredNoneNone
athlete.jpg15.9 KBIgnoredNoneNone
picture.jpg8.39 KBIgnoredNoneNone

#1

vito_a - January 13, 2009 - 02:47

I'm not sure exactly which picture upload form you are using, but trying to guess - shouldn't the url of your form be something like 'user/%user/edit/picture/tpp_picture' ? Probably the 'user/%user/edit/picture' url is already belong to the core user.module or upload.module or something like acidfree gallery module, so it doesn't shows no yours local task on this page. Can you look is there a 'user/%user/edit/picture' local task at 'user/%user/edit' page which is upper one level - which form does it go to?

#2

GuyPaddock - April 11, 2009 - 21:07

I am seeing a similar bug that is not at all related to pictures or the user or upload modules.

See my comment in the "Wildcard Loader Arguments" section of the "Developing for Drupal" manual:
http://drupal.org/node/224170#comment-1464830

Do local tasks support wildcard paths?

#3

florent.jousseaume - June 8, 2009 - 13:23
Version:6.6» 6.11
Priority:normal» critical

I also have a problem with that.

My edit's tab disappear when I create a new URL like user/%/toto/tata.

user/%/toto works and my edit's tab is always visible, but if I add an argument to toto, the edit's tab disappear. After a little search in user.module, it seems to be the user_category_load (wildcar %user_category on edit item menu) function who breaks my tab. This function is for user/%/edit arguments, because he ignores the second and third arguments for URL, and check the new argument in a list of category, but it also check for other url.

What can I do to keep my edit's tab ?

#4

Ryan Palmer - June 26, 2009 - 16:24

Re: #1

The user/%user/edit/picture path points towards a totally custom form. I don't believe Acidfree albums or any other such modules are in use.

#5

elvis2 - June 27, 2009 - 12:04

Do you have the profile module turned on? If so you may need to use the user_category_load() function...

Do a quick bug test, turn off the profile module and then go back to load your picture tab, it might work...

#6

Ryan Palmer - June 27, 2009 - 19:08

Hmm yes that probably has something to do with it. I'll check with the client to see if I can go ahead with such test.

Assuming it does, though.. would that be considered a bug with the profile_menu()? or menu system itself? Shouldn't this type of behaviour be allowed?

#7

coreyp_1 - November 5, 2009 - 23:44

there is a workaround for this, in case anyone else is having this problem.

whatever arg(3) is must also be listed as a category under hook_user().

For example, if your path is user/1/edit/foo, then your hook_user() must contain something like this:

<?php
hook_user
($op, &$edit, &$account, $category = NULL) {
  switch(
$op) {
    case
'categories':
     
$categories = array();
     
$categories[] = array(
       
'name' => 'foo', // this is the important line!
       
'title' => 'Foo',
       
'weight' => 1,
      return
$categories;
      break;
  }
?>

I hope it saves someone else some time!

 
 

Drupal is a registered trademark of Dries Buytaert.