taxonomy_link

Definition

taxonomy_link($type, $node = NULL)
modules/taxonomy.module, line 26

Description

Implementation of hook_link().

This hook is extended with $type = 'taxonomy terms' to allow themes to print lists of terms associated with a node. Themes can print taxonomy links with:

if (module_exist('taxonomy')) { $this->links(taxonomy_link('taxonomy terms', $node)); }

Code

<?php
function taxonomy_link($type, $node = NULL) {
  if ($type == 'taxonomy terms' && $node != NULL) {
    $links = array();
    if (array_key_exists('taxonomy', $node)) {
      foreach ($node->taxonomy as $tid) {
        $term = taxonomy_get_term($tid);
        $links[] = l($term->name, 'taxonomy/term/'. $term->tid);
      }
    }
    else {
      $links = array();
      foreach (taxonomy_node_get_terms($node->nid) as $term) {
        $links[] = l($term->name, 'taxonomy/term/'. $term->tid);
      }

    }
    return $links;
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.