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

Comments

flntobi’s picture

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!

rivena’s picture

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.

flntobi’s picture

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

compugirl’s picture

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

Dora

rivena’s picture

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

Anisa.

dries’s picture

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

Xtraeme’s picture

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!

Xtraeme’s picture

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.

flntobi’s picture

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

I think i'll have to get an upgrade.

greg2’s picture

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.

ob3ron’s picture

It will work if you leave out the leading slash.

ie:
node/number

not
/node/number.

At least, that worked for me. :-)

abg’s picture

Leaving out the first / made it work for me.

Dimm’s picture

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.

silvanasono’s picture

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.

pshafer’s picture

I was having a similar problem, on drupal 5.9. I finally realized that I had two menus with the same path entries. I was trying to use the new menu (with a higher menu id) and sections that had the same paths were not expanding. So I deleted all the entries form the the older menu and they started expanding. I guess we can't have multiple menus with the same paths in them.

danieltome’s picture

I'm using 5.x and it is happening to me too.
I've noticed that if the child menu item, share the path, even if it's not the same, the parent will not expand.

Let me explain with an example:

I have:
One menu:
Parent menu: node/AA
Child menu 1: search/node/BB

When I click on child menu 1. The parent menu expands ok.

Another menu:
Parent menu: node/XX
Child menu 1: search/node/YYY
Child menu 2: search/node/ZZZ

When I click on child menu 1, the parent menu expands ok. But when I click on child menu 2, the parent collapses.

It even happens when using URL aliases and using just: YYY and ZZZ as path.

Does anyone know a workaround?

Thanks and kind regards,

Danno
http://www.danieltome.com

phKU’s picture

True, you can't have more than one menu item being expanded. When there's another item with the same path, Drupal expand only the one with the lowest menu id. At least you can have one working complete expandable menu together with as many of non expandable menus you want. You just have to ensure that each expandable menu item sharing the same path with other always have the lowest id of the duplicates set. To accomplish this, you can easily swap as necessary the menu items from one menu to another in the admin menu config page.