显示所有目录及文章数
像WordPress的类别菜单,如下所示:
- 互联网( 5 )
- 谷歌( 1 )
- 雅虎( 2 )
- Web 2.0的( 1 )
- 杂项( 0 )
<?php<br />
$vid = 1 ; // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from<br />
$items = array();<br />
$terms = taxonomy_get_tree ( $vid );<br />
foreach ( $terms as $term )<br />
{<br />
$count = "(" . db_result ( db_query ( "SELECT COUNT(nid) FROM {term_node} WHERE tid = %d" , $term -> tid )). ")" ;<br />
$termdepth = "" ;<br />
for ( $i = 0 ; $i < $term -> depth ; $i ++)<br />
{<br />
$termdepth = $termdepth . "-- " ;<br />
}<br />
$items [] = $termdepth . l ( $term -> name , "taxonomy/term/$term->tid" ) . " $count" ;<br />
}<br />
if ( count ( $items ) ) { print theme ( 'item_list' , $items );}<br />
?>
