Return to Snippet

Revision: 7928
at August 21, 2008 10:25 by aleprieto


Initial Code
<?php
/**
* Lists terms for a specific vocabulary without descriptions.
* Each term links to the corresponding /taxonomy/term/tid listing page.
*/
$vid = 1;
$items = array();

$terms = taxonomy_get_tree($vid,  0, -1, 1);
foreach($terms as $term){
  $items[]= l($term->name, "taxonomy/term/$term->tid");
}
if(count($items)) {
  return theme('item_list',$items);
}
?>

Initial URL
http://drupal.org/node/247472

Initial Description
This is a simple little block that displays a list of terms in a vocabulary as a list of links to /taxonomy/term/tid pages. Items are listed in the order set for the vocabulary. You could probably use the php sort() function to change that if desired.

Be sure to change the $vid to reflect the vocabulary id of the vocabulary you wish to list. Also, you can change the "taxonomy/term/$term->tid" to any path you wish.

Initial Title
Block that displays terms in a vocabulary as a list of links

Initial Tags
module, drupal

Initial Language
PHP