Menu expand/collapse bug.

Xtraeme - March 4, 2005 - 22:48

I asked this question once before, granted in the wrong forum, and likely because of it didn't receive any feedback. So I'm hoping a second pass in the right place will turn better results :)

Anyways after the original post I learned that the problem I was experiencing extends beyond menu_on-the-fly. For instance try "adding a menu item" to the main navigation tree called "Grandparent" that points to nothing; then add "Parent" beneath it and have it point to node or some other content that actually exists on your site; and finally add another menu item called "Child" that points to nothing or something it doesn't matter.

You can now click on Grandparent and have it expand, but when you go to click on Parent the page loads and the irksome part - the navigation tree collapses back to Grandparent. Obviously not what I had in mind.

I've gone so far as to load up Zend, stepping through each of the calls in menu.inc trying to figure out exactly how the cached serialized output is stored and thus creating this kind of behavior. So far it looks like certain items have garbage values appended to their menu[visible]. To double check this just setup a breakpoint near line 557 ($style = (count($menu['visible'][$mid]['children']) ? (menu_in_active_trail($mid) ? 'expanded' : 'collapsed') : 'leaf'); Yes this is 4.5.2, not the CVS HEAD.

Anyways I hope I'm overcomplicating things, because spending five hours on this kind or problem is the definitely frustrating.

Feedback appreciated,
Dustin

Feedback

flntobi - March 22, 2005 - 13:58

I have the same problem. I don't understand the reason why, but my Menus don't expand as soon they are pointing to a node (whether with alias or URL).

You are right it is frustrating to fight so long with such a tiny problem.

Hope someone helps!

Hm. I don't know if this is

rivena - March 22, 2005 - 14:19

Hm. I don't know if this is in 4.5.2 or not, but what about going to menus, that grandfather menu item, clicking edit, and clicking on 'expanded' to always show it expanded?

Anisa.

Nope

flntobi - March 22, 2005 - 14:25

1. I don't have this option

2. It's not intended to expand everything always, just the one you clicked on.

But thanks anyway

Is this option available to you?

compugirl - March 22, 2005 - 15:01

And if so, what version do you use? I have been looking for a way to keep my menu expanded.

Dora

I'm using the Drupal 4.6 RC

rivena - March 22, 2005 - 15:02

I'm using the Drupal 4.6 RC version. :) It still has some bugs to work out though, so naturally, use with caution.

Anisa.

New Drupal 4.6 feature

Dries - March 22, 2005 - 16:42

That is a new feature in Drupal 4.6RC. :-)

Steven's comment.

Xtraeme - March 22, 2005 - 20:43

If you click on the original post you'll see a comment from Steven that nails this problem dead on.

It seems the solution is to reference 'node/number' not the full URL 'http://sitename/node/number' nor the alias. Once you've done this the menus expand and everything works exactly as one would expect.

I never even considered approaching problem this way, because I wanted the URL to show the alias in the status bar at the bottom of the browser window not the node number. I assumed that by explicitly typing in node/number that it would show exactly that.

So much for assumptions :)

Thanks Steven!

Spoke too soon.

Xtraeme - March 22, 2005 - 22:25

The problem still exists in the normal navigation tree. If you check out http://www.razing.net and click on 'Projects,' then 'Games,' and finally any of Games children you'll notice that the sub-menu Games on the right sidebar will expand, but the normal navigation collapses back to the top.

At least it mostly works.

no it doesn't

flntobi - March 23, 2005 - 17:26

If I use node/number it still doesn't work!

I think i'll have to get an upgrade.

/node/number --> no work for me either

greg2 - June 14, 2005 - 17:23

Drupal 4.6.1 menu module will not expand / contract with or without full URL/node/number or not - Unless you have to remove the full URL from every item in the entire menu. Which I have not done at this time.

leave out the first /

arvana - December 27, 2005 - 07:39

It will work if you leave out the leading slash.

ie:
node/number

not
/node/number.

At least, that worked for me. :-)

What Arvana said

abg - January 28, 2006 - 14:55

Leaving out the first / made it work for me.

Drupal expand / collapse

Dimm - December 15, 2007 - 21:04

Drupal expand / collapse only one menu.
If you create 2 menu with the same(equal) elements and path, the work expand / collapse will be only one menu.

Unique path names for menus

silvanasono - May 13, 2008 - 09:20

I found out that ONE cause of the problem is given by path name .
Actually, in my drupal site I had more than one page with the same name ("URL path settings" set to "about").
The item is considered expanded when it is active or it is always EXPANDED ($type = MENU_EXPANDED).
To check if it is active it calls a function (in function menu_tree in menu.inc) called menu_in_active_trail that finally call another function:
function menu_set_active_item($path = NULL)
This function get the path from the URL and compare it with that of the loaded menu tree that contains ALL the nodes.
So the first node it meets with that path, is stored in a static variable ($stored_mid) and that will be the active node.
So if you have in your menu more than one item with the same path (never mind if alias or default), you will encoutre a similar situation.

I hope it's clear.

 
 

Drupal is a registered trademark of Dries Buytaert.