Placing a menu based on a page’s taxonomy I created a Drupal menu and place the resultant block in the left sidebar. On the block configuration page I went to “Show block on specific pages” > “Show if the following PHP code returns TRUE (PHP-mode, experts only).” and added the following code:

$tid = 0;
$desired_tid = 12;  // Change to the tid you want
$node = menu_get_object();
if ( !empty($node) &amp;&amp; !empty($node-&gt;taxonomy) ) {
  foreach ( $node-&gt;taxonomy as $term ) {
    if ( $term-&gt;tid == $desired_tid ) {
       $tid = $term-&gt;tid;
       break;
    }
  }
}
return $tid;


The menu still showed up on all pages and not just the page that had the taxonomic term that had ID=12.

I then tried using the code:

$desired_tid = 12;  // Change to the tid you want
$node = menu_get_object();
if ( !empty($node) &amp;&amp; !empty($node-&gt;taxonomy) ) {
  foreach ( $node-&gt;taxonomy as $term ) {
    if ( $term-&gt;tid == $desired_tid ) {
      return TRUE;
    }
  }
}


Same effect, the menu still was on all pages. I have disabled caching, flushed the cache, and rebooted the server, all to no affect. Any idea what I might be doing wrong?
If you will put more blocks based on taxonomies or maybe for certain content type i would recommend the context module:

http://drupal.org/project/context

With context you can set conditions with a friendly UI  for display blocks in your drupal instalation.