Return to Snippet

Revision: 3722
at September 6, 2007 05:42 by JuliaKM


Initial Code
<?php
$listlength = 99; // number of terms to show.

$vocabulary_id = 18; // VID of the vocabulary that you need to index

$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);

$items = array();
while ($category = db_fetch_object($result)) {
    $items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid) .'<br />';
  }

print theme('item_list', $items);
?>

Initial URL

                                

Initial Description

                                

Initial Title
print taxonomy terms in a vocabulary

Initial Tags
textmate, drupal

Initial Language
HTML