Вывести список всех словарей и терминов.
Недавно начал работать с друпалом и возникла такая задача. Решил её, написав такой сниппет.
Посоветуйте, оформить эту функцию в виде модуля или приемлемо инклудить её по мере надобности?
<?phpfunction print_vocabulary_terms()
{
$vocs = taxonomy_get_vocabularies();
foreach ($vocs as $voc)
{
$vid = $voc->vid;
print "<li><a href=\"#\">".t($voc->name)."</a>";
$terms = taxonomy_get_tree($vid);
print "<ul>";
foreach ( $terms as $term ) {
$tcount = taxonomy_term_count_nodes($term->tid);
$children_terms = taxonomy_get_children($term->tid);
if (($term->depth == 0) & ($tcount != 0) ) {
print "<li>";
print l($term->name." (".$tcount.")",'taxonomy/term/'
.$term->tid, array('title' => $tcount." posts in "
.$term->name));
if ($children_terms) {
print "<ul>";
foreach ( $children_terms as $children_term ) {
$t_children_count =
taxonomy_term_count_nodes($children_term->tid);
print "<li>";
print l($children_term->name." (".$t_children_count.")", 'taxonomy/term/'.$children_term->tid, array('title' =>$t_children_count." posts in ".$children_term->name));
print "</li>";
}/* end foreach children */
print "</ul>";
}
print "</li>";
}
} /* end foreach */
print "</ul>";
print "</li>";
} /* end foreach */
}?>