diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-10-21 11:12:46 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-10-21 11:12:46 +0000 |
commit | 6777fdb193fb9db01243082b4181ef7637c4ac91 (patch) | |
tree | 80ffe7f9289ec3a15c0374a96e2ff4d6421a4614 /modules/taxonomy.module | |
parent | a9260fa2cd279851db674fa84c1efebfe103ba0d (diff) | |
download | brdo-6777fdb193fb9db01243082b4181ef7637c4ac91.tar.gz brdo-6777fdb193fb9db01243082b4181ef7637c4ac91.tar.bz2 |
- #26583: Make forum taxonomy links redirect to forums rather than taxonomy pages.
Diffstat (limited to 'modules/taxonomy.module')
-rw-r--r-- | modules/taxonomy.module | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 7d5808ceb..d4c4431ff 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -30,18 +30,26 @@ function taxonomy_link($type, $node = NULL) { if (array_key_exists('taxonomy', $node)) { foreach ($node->taxonomy as $tid) { $term = taxonomy_get_term($tid); - $links[] = l($term->name, 'taxonomy/term/'. $term->tid); + $links[] = l($term->name, taxonomy_term_path($term)); } } else { foreach (taxonomy_node_get_terms($node->nid) as $term) { - $links[] = l($term->name, 'taxonomy/term/'. $term->tid); + $links[] = l($term->name, taxonomy_term_path($term)); } } return $links; } } +function taxonomy_term_path($term) { + $vocabulary = taxonomy_get_vocabulary($term->vid); + if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) { + return $path; + } + return 'taxonomy/term/'. $term->tid; +} + /** * Implementation of hook_menu(). */ @@ -866,16 +874,20 @@ function taxonomy_get_term_by_name($name) { * Return the vocabulary object matching a vocabulary ID. */ function taxonomy_get_vocabulary($vid) { - $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid); - $node_types = array(); - while ($voc = db_fetch_object($result)) { - $node_types[] = $voc->type; - unset($voc->type); - $voc->nodes = $node_types; - $vocabulary = $voc; + static $vocabularies = array(); + + if (!array_key_exists($vid, $vocabularies)) { + $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid); + $node_types = array(); + while ($voc = db_fetch_object($result)) { + $node_types[] = $voc->type; + unset($voc->type); + $voc->nodes = $node_types; + $vocabularies[$vid] = $voc; + } } - return $vocabulary; + return $vocabularies[$vid]; } /** |