We Recommend

HTML: The Definitive Guide HTML: The Definitive Guide
They teach you that learning HTML is like learning any other language and that reading a book of rules can only take you so far. Readers begin writing what may be their first Web page just two pages into the book's second chapter. From there on, they provide a wide range of HTML coding to allow readers to learn from good examples. The book includes a handy "cheat sheet" of HTML codes for quick reference.


Posted By

JuliaKM on 09/06/07


Tagged

textmate drupal taxonomy vocabulary


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

basicmagic
kellyharding


print taxonomy terms in a vocabulary


Published in: HTML 


  1. <?php
  2. $listlength = 99; // number of terms to show.
  3.  
  4. $vocabulary_id = 18; // VID of the vocabulary that you need to index
  5.  
  6. $result = db_query_range(db_rewrite_sql("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE d.vid = $vocabulary_id AND n.status = 1 GROUP BY d.tid, d.name ORDER BY name ASC"), 0, $listlength);
  7.  
  8. $items = array();
  9. while ($category = db_fetch_object($result)) {
  10. $items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid) .'<br />';
  11. }
  12.  
  13. print theme('item_list', $items);
  14. ?>

Report this snippet 

You need to login to post a comment.