Fix for 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. $result = db_query_range('SELECT tn.tid, (
  4.  
  5. SELECT count( x.tid )
  6. FROM term_node x
  7. LEFT JOIN content_field_event_start c ON c.nid = x.nid
  8. WHERE x.tid = tn.tid
  9. AND c.field_event_start_value > now( )
  10. ) AS event_count, td.name
  11. FROM term_node tn
  12. LEFT JOIN term_data td ON td.tid = tn.tid
  13. WHERE td.vid = %d
  14. GROUP BY tn.tid', $vid;
  15. while ($term= db_fetch_object($result)) {
  16. $items[]  = l($term->name, "events/$term->tid") . " ($term->event_count)";
  17.   }
  18.  
  19. <div class="taxonomy_list">
  20. <?php
  21. if ( count($items) ) {
  22.   print theme('item_list', $items);
  23. }
  24. ?>

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.