Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created October 4, 2012 19:01
Show Gist options
  • Save claudiosanches/3835692 to your computer and use it in GitHub Desktop.
Save claudiosanches/3835692 to your computer and use it in GitHub Desktop.
Drupal - Get Terms in list format
<?php
/**
* Get Terms in list format (Drupal 6).
*
* Usage:
* Paste in node.tpl.php: <?php print get_terms_list($node); ?>
*
* @param object $node
* Node object.
*
* @return string
* Terms in list format.
*/
function get_terms_list($node) {
if (module_exists('taxonomy')) {
$term_links = '<ul class="terms-list">';
foreach ($node->taxonomy as $term) {
$term_links .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid,
array(
'attributes' => array('title' => $term->description)
)) . '</li>';
}
$term_links .= '</ul>';
return $term_links;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment