Drupal – Using a taxonomy term to control a section header on page.tpl.php

Wanted to store this here, I ended up not using it but I wanted to keep it in case I needed it in the future.


<!-- Get taxonomy term, ID 2 (section background image) to write out section header -->
<?php
     if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
     $node = node_load(arg(1));
     $taxonomy_terms = $node->taxonomy;
     foreach ($taxonomy_terms as $term) {
          if ($term->vid == 2) {
               $ld_bg = $term->name;
          }
      }
    }
?>

<img src="/sites/all/themes/collective/img/<?php print $ld_bg; ?>_bkg.jpg" border="0" alt="<?php print $ld_bg; ?>" />
  1. No comments yet.

  1. No trackbacks yet.

You must be logged in to post a comment.

Valid XHTML 1.1