Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

PicaTeclas

20May/090

Mostrar un listado anidado de términos de taxonomía en Drupal

Buscando cómo mostrar un listado aninado de los términos (terms) de un vocabulario (una categoría de Drupal, o taxonomy), encontré este útil fragmento de código en Drupal.org. Para que funcione esto es necesario usar el módulo Taxonomy.

<?php
            // El ID del vocabulario de la taxonomia del que queremos crear la lista de terminos
            $vid = 10;
 
            $depth = 0;
            $num_at_depth = 0;
            $tree = taxonomy_get_tree($vid);
 
            print "<ul class=\"menu\">\n<li>";
            foreach ($tree as $term) {
            $diffdepth=0;
              if ($term->depth > $depth) {
                print "\n<ul>\n<li>";
                $depth = $term->depth;
                    $num_at_depth = 0;
              }
              if ($term->depth < $depth) {
                $diffdepth= $depth -$term->depth;
                while ($diffdepth > 0){
                    print "</li>\n</ul>\n";
                    $diffdepth -- ; 
                }
                    $depth = $term->depth;
              }
              if (($term->depth == $depth) && ($num_at_depth > 0)) {
                  print "</li>\n<li>";
                }
              print l($term->name, 'taxonomy/term/' . $term->tid);
                $num_at_depth ++;
            }
            print "</li>\n</ul>\n";
?>

El crédito va al autor, billyboylindien

Comentarios (0) Trackbacks (0)

Aún no hay comentarios.


Deja un comentario


Aún no hay trackbacks.