Local tasks not considered in the active trail, causing the trimmed menu to disappear

newdru - February 23, 2007 - 10:21
Project:Menu Trim
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I recently installed menu trim to create context sensitive submenus.

It seems to work well but i've got one buggy predefined menu path:

userlink/all/recent

created by the userlink module:

http://drupal.org/project/userlink

that just does not seem to want to work with menu trim.

if i create a menu item for 'userlink/all/recent' and make it live under a top level primary link that is set to "trim and hide parents" such as:

-Toplevel
---menuitem --> userlink/all/recent ---> menu disappears when you select link to display page = *** menu trim DOES NOT WORK ***
---menuitem --> userlink/all -----------> works correctly (menu trimmed and stays in context when you click)
---menuitem --> userlink/all/everyone--> works correctly (same)
---menuitem --> viewname -----------> works correctly (same)

Basically all paths work (even other ones defined by that same userlinks) with menu trim except that one 'userlink/all/recent' userlink module path?????

It's bizarre. I've tried recreating the item and changing the path to other paths. Nothing seems to fix it but that item does work when i give it another path.

I'm wondering if you might be able to download and install the Version 5 userlink module and just test this for yourself?

NOTEs:

1) i inspected menu table to see what was being done behind the scenes and everything looked ok in the table

2) would you be able to tell me what the menu TYPE means in the menu table? there are numbers like 374, 368 which i think designates 'disabled', 115, etc... It would help me understand the menu system

3) i'm not sure but maybe something is getting cached? are the menus cached? i believe i have caching turned off? how does one clear that cache anyway without having the devel module installed?

thanks

#1

David Lesieur - February 23, 2007 - 22:03

Try enabling the regular (non trimmed) block for your menu. In that block, is the menu context preserved when the current page is userlink/all/recent?

#2

newdru - February 24, 2007 - 01:54

Not sure I follow you but this is what i think you wanted:

1) I kept my original menu trim 1 block and menu trim settings for that (e.g. i did not change them at all). that block is based on menu 'primary links'

2) I went to block and enabled the "standard"/"default" "primary links" menu block (the one my menu trim 1 block is assuming the role of).

3) As a result of steps 1 and 2, I now have two menu blocks visible on my page in the left sidebar - one on top of the other - menu trim 1 (primary links).. followed by block 'primary links'

4) Now i click on "userlink/all/recent" menu item ON PRIMARY LINKS BLOCK (the std menu block that is normally disabled):

a) that menu item on PRIMARY LINKS BLOCK remains highlighted/selected
b) my top menu trim 1 block disappears like i described in the original post

Not sure if that's what you wanted me to do or not.

It looks like the default primary links menu DOES retain focus on that menu item?? These are identical menus (i think). The only difference is that menu trim is applied to one and not the other and performs some magic based upon the menu id of the currently selected menu item. It looks like menu trim is getting tripped up somewhere. When i look in your module though, i don't see it doing anything really other than just printing out the menu path.

Interesting side note, having the two menus blocks (menu trim and the one it is based on without any menu trim functionality) side by side helps me understand a little better what your module does. :-)..

Qs:

1) drupal doesn't care if you put the same path in mutliple menu items does it? (just curious)
2) does drupal menu system make a distinction between the way certain modules define their menu paths? just a thought. maybe the userlink module path that is erroring out is being defined a certain way and menu trim doesn't like it?

any help on this would be great.
thanks

#3

newdru - February 24, 2007 - 01:58

Just wanted to add to the previous post that every other menu item works as desired (e.g. the correct menu is displayed in the menu trim 1 block) when i click on a menu item link in the default primarly links block. it's only that one item from the userlink module.

#4

druru - February 24, 2007 - 09:45

I went looking in the userlink module and i'm not sure if this has anything to do with the problems i'm having but the path i'm trying to use in my trim menu 'userlink/all/recent' is defined as 'MENU_LOCAL_TASK' in menu_hook which is normally presented as a tab.

What i've noticed is that whatever i name the menu item 'userlink/all/recent' under admin menus, automatically renames the tab title that is defined in userlink module for that path????

I'm not familiar enough with menu internals, but i'm starting to think that it is NOT possible to make NAV menu items out of MENU_LOCAL_TASKS..

Any thoughts?

Also if menus are cached how do you clear that out????

thanks

#5

newdru - February 26, 2007 - 23:17

david,

any thoughts on this please?

thanks

#6

newdru - February 27, 2007 - 22:35

For the questioned 'userlink/all/everyone' path, if i put debug statements in your module to check for the return value of this function:

_menu_get_active_trail_in_submenu

that function doesn't return anything on that path.. yet that path is a valid path, exists in my menu trim submenu and is displayed when i click on the link in the ment trimmed submenu???

Note all other menu paths return normally from this function (e.g. are found in the menu path). It's just these user link paths for some reason?

why is this not returning as active trail in the menu path?

thanks

#7

newdru - February 27, 2007 - 23:16

OK.. i think i've figured out the problem. Not sure why? OR if it can be fixed?

If a menu item path is defined in a module as type MENU_LOCAL_TASK (default or otherwise), it is NOT considered to be in the active trail per _menu_get_active_trail_in_submenu function. FYI, local task items appear as tabs on a given page.

That means trim module only works on NON LOCAL_TASK menu items.

Not sure why?

Not sure if it can be amended to use them?

NOTE: I only tested this with userlinks module but i imagine the same behavior can be found in any module. You can confirm this if you like.

#8

DynV - April 1, 2008 - 16:06
Assigned to:Anonymous» DynV

The menu could in fact not be a menu but generated on top of the menu, make sure the module is inserting its branches through the hook_menu as this example show:

<?php
/**
* Implementation of hook_menu().
*/
function test_insert_menu($may_cache) {
 
$items = array();

  if (
$may_cache) {
   
$items[] = array(
     
'path' => 'test_insert',
     
'title' => t('test insert'),
     
'description' => t('Display a test insert.'),
     
'callback' => 'test_insert_page',
     
'access' => user_access('access test_insert'),
     
'type' => MENU_SUGGESTED_ITEM
   
);
  }

  return
$items;
}
?>

#9

DynV - April 1, 2008 - 16:57
Status:active» postponed (maintainer needs more info)

#10

David Lesieur - November 1, 2008 - 21:26
Title:userlink menu path not working with menu trim» Local tasks not considered in the active trail, causing the trimmed menu to disappear
Assigned to:DynV» Anonymous
Status:postponed (maintainer needs more info)» active
 
 

Drupal is a registered trademark of Dries Buytaert.