A PHP snippet that lists terms from given vocabularies with node count.
<?php
/**
* List terms with node count
*/
$result = db_query("SELECT DISTINCT t.tid, t.name FROM {term_data} t WHERE t.vid IN (4) ORDER BY weight,name", $vid);
while ($t = db_fetch_object($result)) {
$count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $t->tid));
$list[] = l($t->name, 'taxonomy/term/' . $t->tid) . " ($count)";
}
if ($list) {
print '<ul><li>'. implode('</li><li>', $list) .'</li></ul>';
}
?>
Comments
Post new comment