diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-12-16 22:05:51 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-12-16 22:05:51 +0000 |
commit | 18d22419f3da39ca4bf92f46d605a25957f311be (patch) | |
tree | d72732b1a23d479c4f2adc4d671d8ec901e2a187 /modules/taxonomy/taxonomy.module | |
parent | 9fe9144ae7804e3b80c0ffd8444b0448261f4436 (diff) | |
download | brdo-18d22419f3da39ca4bf92f46d605a25957f311be.tar.gz brdo-18d22419f3da39ca4bf92f46d605a25957f311be.tar.bz2 |
- Patch #339929 by Moshe et al: move node links into ->content.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r-- | modules/taxonomy/taxonomy.module | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index ebb91459c..219451cfb 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -39,57 +39,45 @@ function taxonomy_theme() { } /** - * 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); - * } + * An implementation of hook_nodeapi_view(). */ -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, - ); - } +function taxonomy_nodeapi_view($node) { + $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; } + + $node->content['links']['terms'] = array( + '#type' => 'node_links', + '#value' => $links + ); } /** |