4.6.x taxonomy.module taxonomy_link($type, $node = NULL)
4.7.x taxonomy.module taxonomy_link($type, $node = NULL)
5.x taxonomy.module taxonomy_link($type, $node = NULL)
6.x taxonomy.module taxonomy_link($type, $node = NULL)

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_exists('taxonomy')) { $terms = taxonomy_link('taxonomy terms', $node); print theme('links', $terms); }

2 calls to taxonomy_link()
chameleon_node in themes/chameleon/chameleon.theme
template_preprocess_node in includes/theme.inc
Process variables for node.tpl.php

File

modules/taxonomy/taxonomy.module, line 47
Enables the organization of content into categories.

Code

function taxonomy_link($type, $node = NULL) {
  if ($type == 'taxonomy terms' && $node != NULL) {
    $links = array();
    // If previewing, the terms must be converted to objects first.
    if (isset($node->build_mode) && $node->build_mode == NODE_BUILD_PREVIEW) {
      $node->taxonomy = taxonomy_preview_terms($node);
    }
    if (!empty($node->taxonomy)) {
      foreach ($node->taxonomy as $term) {
        // During preview the free tagging terms are in an array unlike the
        // other terms which are objects. So we have to check if a $term
        // is an object or not.
        if (is_object($term)) {
          $links['taxonomy_term_' . $term->tid] = array(
            'title' => $term->name,
            'href' => taxonomy_term_path($term),
            'attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))
          );
        }
        // Previewing free tagging terms; we don't link them because the
        // term-page might not exist yet.
        else {
          foreach ($term as $free_typed) {
            $typed_terms = drupal_explode_tags($free_typed);
            foreach ($typed_terms as $typed_term) {
              $links['taxonomy_preview_term_' . $typed_term] = array(
                'title' => $typed_term,
              );
            }
          }
        }
      }
    }

    // We call this hook again because some modules and themes
    // call taxonomy_link('taxonomy terms') directly.
    drupal_alter('link', $links, $node);

    return $links;
  }
}