Posted By

aleprieto on 08/21/08


Tagged

module drupal block


Versions (?)

Block that displays terms in a vocabulary as a list of links


 / Published in: PHP
 

URL: http://drupal.org/node/247472

This is a simple little block that displays a list of terms in a vocabulary as a list of links to /taxonomy/term/tid pages. Items are listed in the order set for the vocabulary. You could probably use the php sort() function to change that if desired.

Be sure to change the $vid to reflect the vocabulary id of the vocabulary you wish to list. Also, you can change the "taxonomy/term/$term->tid" to any path you wish.

  1. <?php
  2. /**
  3. * Lists terms for a specific vocabulary without descriptions.
  4. * Each term links to the corresponding /taxonomy/term/tid listing page.
  5. */
  6. $vid = 1;
  7. $items = array();
  8.  
  9. $terms = taxonomy_get_tree($vid, 0, -1, 1);
  10. foreach($terms as $term){
  11. $items[]= l($term->name, "taxonomy/term/$term->tid");
  12. }
  13. if(count($items)) {
  14. return theme('item_list',$items);
  15. }
  16. ?>

Report this snippet  

You need to login to post a comment.