Testing the value of Fields stored on Taxonomy Terms I have a field (called Division) attached to a node. I want to print out a link (called Switch) on page.tpl.php that varies according to the value of this (node-based) field.

I can successfully do this with the following code:

In template.php

function elite_field_division_helper(&amp;$variables) {
  if ($node = $variables['node']) {
    $field_division = field_get_items('node', $node, 'field_division');
    if ($field_division[0]['tid'] == 1) {
      $variables['switch_site'] = '&lt;a id="switch_site" href="'.$GLOBALS['base_url'].'/business'.'"&gt;Visit Our Business Website&lt;/a&gt;';
    }
    else if ($field_division[0]['tid'] == 2) {
         $variables['switch_site'] = '&lt;a id="switch_site" href="'.$GLOBALS['base_url'].'/home'.'"&gt;Visit Our At Home Website&lt;/a&gt;';
    }
  }

}


In page.tpl.php

&lt;?php if (!empty($switch_site)):?&gt;
  &lt;?php print $switch_site; ?&gt;
&lt;?php endif; ?&gt;


My question is: How can I get this code to work with fields that are attached to TAXONOMY PAGES? (As Drupal 7 allows taxonomy pages to have fields).
Panels is very good for overriding Taxonomy pages. You can have different page and layout variants per vocabulary, user, theme, site etc. You can then include your code in a custom panel pane for taxonomy pages, together with whatever layout or views necessary, or write your own CTools content type for Panels.