Wordpress like category menu in drupal 5, as shown below:
internet (5)
Google (1)
Yahoo (2)
Web 2.0 (1)
Misc (0)
<?php
$vid = 4; // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$items = array();
$terms = taxonomy_get_tree($vid);
foreach ( $terms as $term ) {
$count = "<span>(".db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid)).")</span>";
$items[] = l($term->name, "taxonomy/term/$term->tid") . " $count";
}
if ( count($items) ) { print theme('item_list', $items);}
?>
Since I found the taxonomy_get_tree function returns the depth of each node, I modified the supplied code above like so:
Internet (18)
-- Mail (8)
-- Web (10)
Graphic (52)
-- Photoshop (50)
-- Corel (1)
-- Flash (1)
Security (8)
-- Firewall (2)
-- Anti virus (6)
<?php
$vid = 4; // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$items = array();
$terms = taxonomy_get_tree($vid);
foreach ( $terms as $term )
{
$count = "(".db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid)).")";
$termdepth = "";
for ($i=0;$i<$term->depth;$i++)
{
$termdepth = $termdepth . "-- ";
}
$items[] = $termdepth . l($term->name, "taxonomy/term/$term->tid") . " $count";
}
if ( count($items) ) { print theme('item_list', $items);}
?>
Specifically, adding the inner for...loop to add the -- characters one time for each depth level. If you have too many levels and you don't want to return them all to this list, then call taxonomy_get_tree with the fourth parameter being the max depth.