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

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.