I have nodes associated to more than one taxonomy vocabulary, so the same node can be listed/reached in different ways, for example:

Brand > Family line > model > NODES

Veicles > category > NODES


Ferrari > Top-Luxury > Testarossa > NODES > NODE-A

Cars > Supercars > NODES > NODE-A

By Design every node can have only and only one URL: it's ok for me (and for SEO)

Now I have created different taxonomy menus (based on the above taxonomies) to retrieve nodes in different ways:

TAXONOMY MENU A: Ferrari > Top-Luxury > Testarossa > NODE-A

TAXONOMY MENU B: Cars > Supercars > NODE-A

The question is: is there a way to keep expanded the specific taxonomy menu the user has used to reach the node?


if user has reached NODE-A trough MENU A then MENU A is showed and expanded in the page

if user has reached NODE-A trough MENU B then MENU B is showed and expanded in the page

Is there a way to accomplish this?

May be using SESSION variables? (ref: http://drupal.org/node/1443210 )

Thank you very much for any help

1 Answer 1


I've done this in my modules hook_init() implementation by using sessions, menu_get_object and menu_tree_set_path(). Here's some example code showing my general approach:

function mymodule_init() {
  // Save the active path for users when on taxonomy term pages.
  if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(2)) {
    $_SESSION['mymodule_path'] = $_GET['q'];
  // The user is on a node page.
  if (arg(0) == 'node' && arg(1)) {
    $node = menu_get_object();
    // Assuming all the nodes in the taxonomy menu are of the same specific type.
    if ($node->type == 'mynodetype') {
      if (isset($_SESSION['mymodule_path'])) {
        menu_tree_set_path('menu-mymenu', $_SESSION['mymodule_path']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.