(Tutorial) How to display taxonomy terms from an individual vocabulary separately in Drupal
Tips : How to display taxonomy terms from an individual vocabulary separately in Drupal
By default drupal prints out all terms from all vocabularies in the same place. Sometimes this is fine, but there are definitely occasions where it is preferable to have control over where each vocabulary is displayed on and individual basis. Fortunately Drupal can be made to do just about anything if you understand how it works. Below is a function I wrote that allows you to isolate a particular vocabulary for display where ever you want. The code below should be pasted into your template.php file.
<?php
/* This function accepts nid, vid and a string "name" which is used to print out the terms of an individual vocabulary*/
function individual_vocabulary_list($nid, $vid, $name) {
$terms = taxonomy_node_get_terms_by_vocabulary($nid, $vid);
if ($terms) {
$links = array();
$output .= t($name) . $vocabulary->name . ': ';
foreach ($terms as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
}
$output .= implode(', ', $links);
}
return $output;
}
?>
Courtesy : Translationdesigns.com
- guru's blog
- Login to post comments
![Drupal-6-Book-[Building Powerful and Robust Websites with Drupal 6].jpg](http://www.drupalranch.com/images/Drupal-6-Book-[Building%20Powerful%20and%20Robust%20Websites%20with%20Drupal%206].jpg)