How to use "Show Block on Specific Pages when PHP code returns True" - to make menu appear based on taxonomy terms for node???

Anybody know how to use the "Show block on specific pages when PHP code returns True" to have a menu block appear based on a nodes taxonomy term as well as when a taxonomy term is hit and loads a list of nodes??

I thought taxonomy_context was the answer but I cant add menu items to it like links to pages or blogs. I thought taxonomy_menu was it but it is not updated for 4.7..... any help would be greatly appreciated.

Can anyone improve on this code

jeffreydalton.info - June 30, 2006 - 17:01

I am a php / drupal newbie so I am looking for someone to improve on this if interested. This code gets dropped into a menu block with the settings for 'php code returns true' to show the menu. You can define what terms get the menu attached so nodes with those terms get the menu attached. This functionality would be sweet as part of the menu module. Some way to pick taxonomy terms to stick menus to. This code works with the taxonomy_context module installed and with all the settings set to 'disabled'.

<?php
$arg1
= arg(1);
$arg2 = arg(2);
$taxArray=taxonomy_node_get_terms($arg1);

$parseCall = $arg1.$arg2;
switch (
TRUE){
    case (
$taxArray[2]->name != ""):
       
$showMenu = TRUE;
        break;
        case (
$taxArray[10]->name != ""):
       
$showMenu = TRUE;
        break;
    case (
$parseCall == "term2" || $parseCall == "term3" || $parseCall == "term4" || $parseCall == "term5" || $parseCall == "term17"):
       
$showMenu = TRUE;
        break;
        case (
$parseCall == "term10" || $parseCall == "term11" || $parseCall == "term12" || $parseCall == "term13"):
       
$showMenu = TRUE;
        break;
   
//This line will load menu for vocabulary terms if needed
        //case ($parseCall == "vocabulary3"):
    //    $showMenu = TRUE;
    //    break;
   
default:
       
$showMenu = FALSE;
    }
return (
$showMenu == TRUE);



?>

 
 

Drupal is a registered trademark of Dries Buytaert.