Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm having a real big headache with the menu system and I almost thought that this module would solve all my problems in this life. But the reality hit back with local tasks.
Description of the setup
- I have set up the node hierarchy and menu block modules
- I created a node "Parent" and put it to the primary menu
- I created a node "Child 1" and set its parent to be "Parent"
- I created a node "Child 1.1" and set its parent to be "Child 1"
- So the hierarchy is now
Parent
- Child 1
-- Child 1.1
Description of the problem
- I have a module that adds local tasks (tabs) to nodes in a similar way that the devel module does (Dev load, Dev render in the Devel module)
- When I navigate to Child 1.1 and click on the local task (tab), the menu block provided by this module disappears completely!
- I noticed the same thing happens with "Dev load" tab provided by the Devel module so I guess the problem is not just in my module.
Are there any known issues regarding local tasks? I searched the issue que but couldn't find anything.
All help is highly appreciated and if some additional information regarding the menu block settings or my hook_menu are needed I'm more than willing to give them.
Comments
Comment #1
masipila CreditAttribution: masipila commentedComment #2
masipila CreditAttribution: masipila commentedI've been struggling with the menus today and it looks like this is related to the menu wildcards that I use in hook_menu().
The setup is like this.
A "league" has tabs "League home", "Teams", "Games" and "Standings".
The tabs are defined like this:
"League" is in the special menu created with this module. When I navigate to any of the tabs (local tasks) (teams, games, standings), the whole League disappears from the menu.
I've been struggling with the wildcard loaders with normal menus as well (not created with this module). When I navigate to the tabs of the league (local tasks), the menu loses the trail and collapses.
Comment #3
masipila CreditAttribution: masipila commentedHere's my workaround for this issue just in case somebody else is having similar problems with local tasks / tabs defined by wildcards in hook_menu.
My understanding of the situation is that the "local task" menu items are stored in {menu_links} database table in such a way that their parent menu item will collapse when we are viewing the tab. BUT it seems to be that this happens only when local tasks are defined using wildcards. If the local task is defined explicitly without wildcards, then the parent item won't collapse. This is a more generic phenomenon in the menu system but I'm almost sure it's the same reason why the menu block defined by this "Menu block" module disappeared as I described in the first post of this issue.
The CCK content.module is an example where the local tasks are defined using a Drupal 5 style foreach-loop. There the parent item won't collapse. Using a D5 style foreach-loop like this is something you probably want to avoid.
Anyway, finally to my workaround.
This is what I wanted to achieve. For now, you can see this in action on the old Drupal 5 based site:
http://www.curling.fi/en/competitions/finnish-championships
Primary menu item located in the top of the page:
- Leagues and Tournaments
"Submenu" of "Leagues and Tournaments" located on the left sidebar
Leagues and Tournaments
- Finnish Championships
-- Men's Championships 2010-2011 // this is a "league"
-- Women's Championships 2010-2011 // this is a "league"
-- Etc.
Each league has local tasks that are rendered as tabs:
- League home
- Teams
- Games
- Standings
So the whole menu hierarchy looks like this:
Primary menu
- Leagues and Competitions
-- Finnish Championships
--- Men's Championships 2010-2011 // league
---- League home // default local task
---- Teams // local task
----- Team A // callback menu item, link provided from the content of "teams" page
----- Team B
----- Team C
---- Games // local task
---- Standings // local task
So here's the way I worked it out for my D6 version of the module:
I hope this description helps if somebody else is struggling with menu wildcards and tabs created with local tasks.
Comment #4
masipila CreditAttribution: masipila commented