I'm trying to get the ubercart catalogue taxonomy to work with dhtml_menu by using the taxonomy_menu module.

The issue I am having is when you select the option 'keep only one menu open at a time' and select 'custom path' in taxonomy_menu to get it to point to catalog/%. It doesn't remember where you are in the menu and hence it doesn't expand the menu you are in.

Is this an issue with dhtml_menu or taxonomy_menu?

Let me know if I can help solve this issue in any way.

Comments

cburschka’s picture

Title: Issue with taxonomy_menu » taxonomy_menu, active trail is not expanded.
Project: DHTML Menu » Taxonomy Menu
Version: 6.x-3.4 » 6.x-2.x-dev
Component: PHP Code » Code

This is an interesting problem; unfortunately, I doubt that DHTML Menu can fix it.

See, DHTML Menu finds the "active trail" (the official term for the menu item of the current page) by checking a certain parameter (the fourth, named $in_active_trail) passed to theme_menu_item(). If it is TRUE, then the item is in the active path (and is displayed as expanded), otherwise it isn't. menu_tree_output() in turn gets this flag from the $tree[$menu_item]['link']['in_active_trail'] element in the $tree it is supposed to render.

In other words, by the time DHTML Menu gets to work on the menu tree, the tree is supposed to already contain the information whether each particular element is in the active trail. If the tree build by taxonomy_menu isn't adding the information, then that is likely to be a bug in taxonomy_menu.

summit’s picture

I too have the problem taxonomy_menu somehow doesn't remember where you are in the menu...
May be duplicate: http://drupal.org/node/426304
greetings, Martijn

indytechcook’s picture

Status: Active » Postponed (maintainer needs more info)

When you say the menu isn't acitve, are you on a node with a term or the exact page from the menu?

Taxonomy menu doesn't build the menuu tree on display, it only save the menu link to the db.

arlinsandbulte’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

No reply after a few months of "postponed (maintainer needs more info)"
In the interest of cleaning things up, I am marking as duplicate of #426304: [NOT SOLVED] Hierarchical menu, NOT expaning to current term

Please go ahead and correct me and/or change status if I am wrong

summit’s picture

I waited on response of Arancaytar, Yes I am on a node with a sublevel term, and then the taxonomy menu doesn't expand to the right level, it stays on toplevel.
greetings, Martijn

enkara’s picture

Version: 6.x-2.x-dev » 6.x-2.7
Status: Closed (duplicate) » Active

Is there a way to fix this? I am having the same problem and I don't think the issue marked as duplicate is the same issue.

The problem is that with the option "Keep only one menu open at a time" activated, menus created by taxonomy menu don't stay expanded on the active item.

enkara’s picture

No solutions after a year? Someone must have fixed it

indytechcook’s picture

Status: Active » Closed (duplicate)

@enkara As stated in comment 3, taxonomy menu does not build the menu tree and there for has nothing to do with setting one active.
Related issues:
#664102: Expand menu on node page

http://drupal.org/project/taxonomy_menu_trails

enkara’s picture

taxonomy_menu_trails doesn't solve the problem

If it's not dhtml menu fault nor taxonomy menu fault, where is the problem then? In core menu system? I can't understand why when you have the "Keep only one menu open at a time" disabled, the active menu remains opened and not in the other case. And I don't know why this happens only with the menu generated by taxonomy menu.

What's wrong here?

(I'm not complaining, thank you for this module, but it seems like nobody is interested in having a solution for this, if I knew in wich module I had to search for the problem I would do it, I just need a clue)

summit’s picture

Hi, did you see #8, http://drupal.org/project/taxonomy_menu_trails this module was the glue between the menu system and taxonomy_menu for my problem.

EDIT: somehow it doesn't work anymore..what could it be?
greetings, Martijn

enkara’s picture

This doesn't solve my problem.

What I can't understand at all is why it is kept expanded in one mode but in the other not.
I'm going to start to look into the code, but I don't know wich module is the guilty.

Any help will be appreciated.

thank you

indytechcook’s picture

Core is where it's at. That is what determines what page your are on and there for what menu. Taxonomy Menu only saves the menu links and does not have anything to do with the display/rending.

Acording to Arancaytar,6 dhtml menu overrides the theme function http://api.drupal.org/api/function/theme_menu_item/. If you are using the core menu block, this is is called from http://api.drupal.org/api/function/theme_menu_item/ which is passed the menu tree by http://api.drupal.org/api/function/theme_menu_item/ which generates the menu tree using http://api.drupal.org/api/function/menu_tree_page_data/6.

http://api.drupal.org/api/function/menu_tree_page_data/6 is a mess. It looks like a variable called 'menu_expanded' can influence this. menu_tree_page_data also uses http://api.drupal.org/api/function/menu_tree_data/6 which calls http://api.drupal.org/api/function/_menu_tree_data/6 which calls itself recursively.

Finally in _menu_tree_data you will find the following lines of code

    // We need to determine if we're on the path to root so we can later build
    // the correct active trail and breadcrumb.
    $item['in_active_trail'] = in_array($item['mlid'], $parents)

And there, my friend, is where the 'in_active_trail' key is set.

The above is only if you are using the core menu block. There is nothing stoping any other module (or theme) from called theme('menu_item') and sending it whatever they want.

I can tell you that _menu_tree_data is the source of my pain also for other issue. I know it's been rewritten for D7 (and hopefully patched back)

Cheers!
Neil

mcrittenden’s picture

I had this problem using Taxonomy Menu + DHTML Menu. Since DHTML menu already outputs the entire menu structure (i.e., instead of just the top level menu items and the active trail like core menus), I was able to solve it with a bit of JS that looks for a link with class="active" and moves up the chain, expanding all the parent UL's.

Here's that code:

$('ul.menu li.dhtml-menu a.active').parents('li').removeClass('collapsed').addClass('expanded').find('ul:first').css('display', 'block');

Yes, it relies on JS, but so does DHTML menu so I'm not really losing anything by doing it that way.

Also, taxonomy_menu_trails does NOT fix this, as that module only sets the active trail when on a node page, not when on a taxonomy listing page or (in the OP's case), an UC Catalog page.

enkara’s picture

mcrittenden you saved my life!! As I don't know very much javascript I didn't even thought of that solution. You rock, I owe you a beer

summit’s picture

Hi,
Could this solution be integrated in taxonomy_menu without using dhtml_menu please?
Thanks a lot in advance for considering this!

greetings,
Martijn

shv_rk’s picture

Hello,

I am having the same issue.
would you please describe where should I add this line of code?
$('ul.menu li.dhtml-menu a.active').parents('li').removeClass('collapsed').addClass('expanded').find('ul:first').css('display', 'block');

regards

mcrittenden’s picture

Note that shv_rk emailed me and I responded there. Here's my response:

The easiest place to add it is in your theme. Add a themename.js file, put that code in it, surround that code with:

$(document).ready(function(){ 
    ......... code goes here ............
}) 

...(that part makes sure the code runs when the page loads) then save it, and tell your theme to include that JS file (this is done using your themename.info file: http://drupal.org/node/171205#scripts) ...then you should be good.

If you have trouble, hop into the #drupal IRC channel on irc.freenode.net ...there are usually about 500 people in there, and many of them will be willing to help you.

hacmx’s picture

thanks man!, you save me too!!, U rocks !!
Greetings! ;)

summit’s picture

Hi, Will this also work on D7 please?
Anyone tested this?
greetings, Martijn

alertby’s picture

hi
in file sites/all/modules/dhtml_menu/dhtml_menu.theme.inc in line 48 remove && !$l['in_active_trail']

code will look:

  if ($l['has_children'] && !in_array($variables['element']['#attributes']['id'], $cookie)) { // && !$l['in_active_trail']
    $variables['element']['#attributes']['class'][] = 'collapsed';
    $variables['element']['#attributes']['class'][] = 'start-collapsed';
  }