Created
October 4, 2012 19:01
-
-
Save claudiosanches/3835692 to your computer and use it in GitHub Desktop.
Drupal - Get Terms in list format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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