Hierarchical menu, NOT auto expaning not working ok
Summit - April 7, 2009 - 13:28
| Project: | Taxonomy Menu |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Description
Hi,
Without option: Auto Expand Menu Item Sets the expand setting to TRUE only the top hierachy terms are shown.
See: www.aanbiedingen-vakanties.nl second block on the left.
When I use Auto Expand Menu Item Sets the expand setting to TRUE the whole taxonomy tree is shown.
See attached picture.
So the bug only occurs when Auto Expand Menu Item Sets the expand setting to TRUE is NOT selected.
Thanks for going into this!
Greetings,
Martijn
| Attachment | Size |
|---|---|
| taxonomy_menu_auto_expand_menu_items.JPG | 113.2 KB |

#1
I saw this issue also. I think I may have accidentally fixed it when I was fixing another issue. Please download the dev dated after this post and let me know.
Thanks,
Neil
#2
No dev yet later than 2-april. Will do Neil. Thanks for the update.
EDIT: On dev (6.x-2.x-dev (2009-Apr-09) it is not working, sorry..
greetings,
Martijn
#3
Hi Neal,
Taxonomy Menu 6.x-2.x-dev (2009-Apr-16) also not working yet.
I only see the top-terms if I do NOT auto expand.
Sorry to have to report this. Greetings, Martijn
#4
I have the same problem with latest dev version.
The problem only appears with Menu Path: Hierarchy, Custom Path seems to be ok.
When "autoexpand" option is disabled only vocabulary will be shown (item for vocabulary enabled) and first term level expands when clicking on vocabulary. Other deeper levels are not shown.
#5
Ok. I'll retest with the Hierarchy path.
#6
I was also able to reproduce this in version 2.3. When is the last time that the hierarchy path worked correctly?
#7
I haven't seen it working correctly for over a month now, do not know when the error started.
Hopefully you find the cure :)
Greetings,
Martijn
#8
There is an interesting behaviour that I can see also with "Menu Path: Custom".
Mmh - how can I explane it..
Settings in TM: "Menu Path: Custom" / "Display Depth in Custom Path: 1" so two arguments get passed to the view.
1) When I use for VIEWS page "path = category/%" (just one %) I get two different results:
1a) "Auto Expand" is enabled: Whole menu shows up
1b) "Auto Expand" is disable: Only vocabulary item shows up (or first hierarchy level when "item for vocabulary= disabled)
2) VIEWS page path = category/%/% (two %)
2a) With this path the menu shows up correctly no matter if "Auto Expand" is enabled or disabled.
Considering this behaviour the path for "Menu Path: Hierarchy" should be category/%/%/%/% (VID/TID/TID/TID) when having three hierarchy levels.
The following is happening:
3a) path = category/% / Auto Expand" is enabled: Whole menu shows up
3b) path = category/% / Auto Expand" is disabled: Only vocabulary and first level of terms show up (not expanded)
3c) path = category/%/%/%/% / Auto Expand" is enabled: only 3rd level
3d) path = category/%/%/%/% / Auto Expand" is disabled: only 3rd level (same as 2c)
So why this different behaviour?
For 2a) Both arguments are always there, so category/%/% fits for all cases.
For 3c+d) The number of arguments is only true for the third level of terms.
When directly typing an URL adress with category/vid/tid (like downloads/10/184) or category/vid/tid/tid it works fine with path=category/%. So this seems to be the right thing looking from VIEWS side.
I think the described problem has to do with menu_callback_for_free_hook_into_sth [:-)] and its ability to find an excisting path.
(I´m not sure if it gets clearer now after this whole comment)
Klaus
(Neil, how is TM3 doing? I have nearly completed my community side, without a single line of PHP programming myself - thanks to Drupal Community - I could realize much more than I expected in the beginning - most time I spent with checking modules - just the frontpage needs some more designing -
I´m experimenting with ddblocks to give it some touch of aliveness.)
Martijn, do you use VIEWS for your Hierarchy Path or how do you realize it?
#9
Hi,
As explained by Neil, I use a view with argument to get the Hierarchy Path. But it only shows the first depth of terms the last month.
Greetings, Martijn
#10
Martijn, how many arguments you are using withing withing the view? What path?
#11
Hi, Here is my view explained: http://drupal.org/node/402888#comment-1373796
Greetings, Martijn
#12
I spend time time doing some debugging in the different situation above. What I could see, the data is being stored in same way in the menu_links table. All taxonomy menu does is save data to that table using the menu_link_save function. It does have something to do with how Drupal displays the menu but I'm not sure where yet. I haven't dug through the core menu code or searched through current bugs.
In Martijn's situation, the URL is changing but what is sent and processed by Drupal is still cateogry/vid/tid/tid and therefore the same way as any other view. I thought you had this working at one time? What happened?
#13
Hi Neal,
Yes after thorough investigation I think it was still working on the downloaded .dev version of April 9th, but after this date somehow only the top-terms are shown using the hierarchical Menu Path type. The latest version somehow also not has the view which to choose from anymore?
I thought may be the Custom Path may be needs this one from the latest code, but enabling this type didn't gave back view-selection choose within taxonomy sceen?
Greetings,
Martijn
#14
Hi Neal, I attach a screenshot of a working version of hierarchy 9the April version. As you can see, there is the view to choose from.
In the latest .dev version (16 April). The Name of View option is not there anymore..
May be this has to do with this issue?
As you can see on this site: http://www.kies-een.nl/ , it is not working anymore, only the top-terms are shown.
greetings,
Martijn
#15
That's strange. I don't remember ever having that feature in v2. I'll look back through my versions and see what changes have been made.
#16
Hi Neal,
It was in that version necessary to have a view to get the hierarchical option if I remember correct. If that is not needed anymore, ok, but how then proceed?
I can send you in winzip the working 9th april version I have, if you want that?
Greetings, Martijn
#17
Go ahead and send it. Was that the custom module I put together for you?
#18
Ok, I do not know if it was part of the custom module or integrated, I send what I have in the 9th april version. As you know, Drupal is hobby, not my daytime job. I try to send it tonight. Thanks for investigating further!
EDIT: Hi Neil, with disabling the custom module, the view field is gone, but the hierarchy is still working.
Send you through Linkedin a mail. Don't have you're email anymore..sorry. Please reply with correct email.
Greetings, Martijn
#19
Got it Martijn, I'm looking at it now.
#20
Well, the version you sent me is the same as the dev. Shoot, I thought we were close. What version of Drupal Core are you running? Did it change? I know i updated to 6.1. I was going to go back and see if it's a difference.
#21
Hi Neal, 6.11. may be others in this thread can contribute also.
In holland it is Queensday today. So I am off having a drink and joint!!
EDIT: Queensday became a disaster because a grazy guy hit a car into the audience where the queen would pass..
Did you find a solution please for this auto-expanding?
greetings, Martijn
#22
Hi Neal,
Using the latest 6.2-dev from 31 may, using menu-path-type "hierarchy", not-autoexpanded is still not working.
With the nodes, the menu will not expand to the right terms.
See: http://www.kies-een.nl/europa/nederland/noord-holland/amstelveen
The menu to the right should expand to
-Europa---Nederland
-----Noord-holland
----------Amstelveen
See picture that noord-holland, amstelveen is indeed the hierarchy
Thanks for still going into this and greetings,
Martijn
#23
Hi may be somehow related to http://drupal.org/node/317753
thanks for going into this again!
greetings, Martijn
#24
Could it have to do with this peace of code I use in settings.php, to get hierarchical templates?
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
//The vocabulary which needs url_rewrite with taxonomy_menu enabled
$vid = 2;
// Get ID's: [VID]/[TID]/[TID]etc.. out of taxonomy_menu and place them in $matches ARRAY
if (preg_match('|^category(/.*)|', $path, $matches)) {
//If the $vid matches the [VID] within the taxonomy_menu ARRAY then url rewrite
if ($matches[1] = $vid) {
$ids = explode("/", $path);
if (is_numeric($ids[5])) {
$term = taxonomy_get_term($ids[5]);
$path = "plaats/". $term->name."/";
}
if (is_numeric($ids[4])) {
$term = taxonomy_get_term($ids[4]);
$path = "provincie/". $term->name."/";
}
elseif (is_numeric($ids[3])) {
$term = taxonomy_get_term($ids[3]);
$path = "land/". $term->name."/";
}
elseif (is_numeric($ids[2])) {
$term = taxonomy_get_term($ids[2]);
$path = "continent/". $term->name."/";
}
elseif ($path <> '') {
$path = 'regionaal';
}
$options['base_url'] = 'http://www.kies-een.nl';
$options['absolute'] = true;
}
}
}
#25
Is this issue still active was there a solution?
#26
this is still an issue. last tie mi was debugging it i got hit by the menu module. I need to look into this again. It's surprises me with 7K installs that people haven't complained more.
#27
I wasted a day playing with this module today. If used a custom path for my own MENU_HOOK - i.e. a defined in hook_menu, then top level menu never expands. I assume this because it requires a view.
Ended up using the hooks to generate my own menu based on the MENU_HOOK already created ('products').
function xxxx_taxonomy_menu_delete(&$item) {
$term = taxonomy_get_term($item['tid']);
if ($term->vid != 1) // product category
return;
$name = preg_replace("/ /i","-",$term->name);
$path = "gallery/" . $name;
menu_link_delete(null,$path);
return;
}
function xxxx_taxonomy_menu_insert(&$item) {
if ($item['tid'] == 0){
$item['remove'] = true;
return;
}
$term = taxonomy_get_term($item['tid']);
if ($term->vid != 1) // product category
return;
$plid = _get_mlid('products');
$item['plid'] = $plid;
$desc = $term->description;
trim($desc);
$desc = (strlen($desc) >0)? $desc : $term->name;
$path = "gallery/" . preg_replace("/ /i","-",$term->name);
$menu = array("link_path" => $path,
"link_title" => $desc,
"menu_name" => "navigation",
"router_path" => "gallery",
"weight" => $term->weight,
"plid" => $plid
);
$result =menu_link_delete(null,$path);
$result =menu_link_save($menu);
$item['remove'] = true;
}
#28
Hello bluffit, I'm glad you got it working. That is a very creative workaround.
When I have extra time, this is my number one priority for this module.
#29
I"m working on this and issue #514640: Duplication of terms on and off for the next few hours. I'll be on IRC if anyone wants to assist. indytechcook
#30
After hours of debugging and research, it seems these are linked to issues with the core menu system.
#550254: Menu links are sometimes not properly re-parented
#149562: Menu module causes duplicate menu items
#566094: menu_tree_data() doesn't build proper hierarchy
Some of the times say they are for D7 but also apply for D6. I haven't tested any of the patches yet.
#31
Hi
From what I saw of your code, it seems that you needed to be able to allow a router path for custom module functions (not just views). If this was done, and the parent able to be specified properly, it should work.
As you can see from the code above, I can generate the correct menus from the available data ...?
#32
Thanks for the suggestion bluffit. The router path 'taxonomy/term/%' does exist for the menu links. If it didn't , then none of the menu items would show for the path type. The issue is reproducible using the default path type also.
All of the data is stored correctly in the menu_links table. I've done several comparisons to workflows that work and others that don't. Even after rebuilding the menu, the rows in the menu_links table are correct. If the router path didn't exist, then the row would have been deleted.
I've debugged where the issue is at. The menu tree variable isn't been created correctly in the menu_tree_data/_menu_tree_data function in menu.inc of core. I've narrowed down the issue to those function, I just haven't had an opportunity to debug any farther.
The function _menu_find_router_path would find the correct router path, but this is already called from menu_link_save.
The issue is very easy to reproduce. Just select "use 'all' at the end of the url' You don't even have to use taxonomy_menu. I had issues adding taxonomy/term//all via a menu link manually on admin/build/menu. I know the router item exists because you can go to the page and it returns data (with or without the view enabled). They both use the same router path so I'm not sure why they both wouldn't work.
Don't get me wrong, I would love for that solution to work, I just don't think it will.