Fix for Gets list of taxonomy terms

  1. <?php
  2. $vid = 3;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
  3. $items = array();
  4.  
  5. $terms = taxonomy_get_tree($vid);
  6. foreach ( $terms as $term ) {
  7.   $count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid));
  8.   if ($count > 0) {
  9.         $items[] = l($term->name, "events/$term->tid") . " ($count)";
  10.         }
  11. }
  12. ?>
  13. <div class="taxonomy_list">
  14. <?php
  15. if ( count($items) ) {
  16.   print theme('item_list', $items);
  17. }
  18. ?>

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.