Аватар пользователя Dima

Вывод терминов таксономии с субкатегориями и кол-вом матереалов в них

  1. <?php
  2. $vid = 9; /* <---- put correct vocabulary ID here */
  3. $terms = taxonomy_get_tree($vid);
  4. print '';
  5. foreach ( $terms as $term ) {
  6. $tcount = taxonomy_term_count_nodes($term->tid);
  7. $children_terms = taxonomy_get_children($term->tid);
  8. if ($term->depth == 0) {
  9. print "";
  10. print l($term->name." (".$tcount.")",'taxonomy/term/'
  11. . $term->tid, array('title' => $tcount." posts in "
  12. .$term->name));
  13. if ($children_terms) {
  14. print "";
  15. foreach ( $children_terms as $children_term ) {
  16. $t_children_count =
  17. taxonomy_term_count_nodes($children_term->tid);
  18. print "";
  19. print l($children_term->name." (".$t_children_count.")",
  20. 'taxonomy/term/'.$children_term->tid, array('title' =>
  21. $t_children_count." posts in ".$children_term->name));
  22. print "";
  23. }/* end foreach children */
  24. print "";
  25. }
  26. print "";
  27. }
  28. } /* end foreach */
  29. print "";
  30. ?>