Use taxonomy associated with a node to display "context-sensitive" menu (need help)

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by webdrips on January 26, 2010 at 6:42am

Hi all.

Using Drupal 6, I am looking to use a simple taxonomy association to set up an automated method of displaying "context sensitive" menus where only the parent/children with the associated matching term are shown in one (and only one) block.

So, for example, if my Primary menu/node set up is as follows

  • Products
    • Product A
      • More about A
      • More about A
    • Product B
      • More B
  • Services
    • Service 1
    • Service 2
  • ...

Then if the taxonomy term "Products" is associated with each of the items in the first primary bullet, I'd like to display the associated parent menu item associated with Products and all children of Products menu items in a block whenever any of the Product nodes are viewed, but I don't want to show Services for example.

(I'll likely use the taxonomy for several other things and the user will have the option to select "none" for no taxonomy and thus no menu in case anyone is wondering why I chose this path.)

In the past, I set up separate blocks/user menus for Products, Services, etc., but that is obviously high maintenance and requires a menu item be set in two places.

I looked at several modules, the closest being Menu block, but they all had their flaws/limitations. For example, Menu block requires creating one block per menu and there is no option to not include some of the menu items.

It was also simple enough to grab a node's taxonomy term name and simply display an entire menu using print menu_tree('menu-custom-name');, but then I'm back to creating a user menu for each parent item in the Primary menu, which is not desirable.

So, any help would be most appreciated (and I'll buy you a drink at DrupalCon SF if you will be there).

Thanks in advanced,

Dan

Note, here's the simple code I'm using so far:

<?php
$node
= node_load(arg(1));
if(
$node) {
foreach(
$node->taxonomy as $term) {}
switch (
$term->name) {
case
'Products':
print
menu_tree('menu-products');
break;
case ....
}
}
?>

Taxonomy

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /