Posted By

level09 on 11/10/09


Tagged

output drupal taxonomy custom Terms templatephp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ReeceMarsland


Render Taxonomy Terms based on Vocab ID


 / Published in: PHP
 

  1. function render_terms($node,$vocabid,$title=null,$divclass=null) {
  2.  
  3. $terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabid );
  4. if ($terms) {
  5.  
  6. $output = '<div class="field field-item'. ' '.$divclass .'"><div class="field-label-inline-first">' .$title .' </div> ' ;
  7. $term_links = array();
  8. foreach ($terms as $term) {
  9. $term_links[] = l($term->name, taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description)))) ;
  10. $output .= implode(", ", $term_links);
  11. }
  12. }
  13. $output .='</div>';
  14. return ($output);
  15. }

Report this snippet  

You need to login to post a comment.