Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Ok, so it's not a patch, but here's my suggestion:
taxonomy_link() generates the links used in the "submitted by x in category foo" section of nodes (and probably other places). The link it generates is "taxonomy/term/whatever". This is great for stories, but for other node types it isn't.
I've squeezed in a simple if() to check if the node is a forum post. If it is, then it generates a link of the format "forum/whatever" so that the user is directed to the regular forum listing instead of an ugly node listing.
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);
if ($node->type == 'forum') {
$links[] = l($term->name, 'forum/'. $term->tid);
} else {
$links[] = l($term->name, 'taxonomy/term/'. $term->tid);
}
}
}
else {
$links = array();
foreach (taxonomy_node_get_terms($node->nid) as $term) {
if ($node->type == 'forum') {
$links[] = l($term->name, 'forum/'. $term->tid);
} else {
$links[] = l($term->name, 'taxonomy/term/'. $term->tid);
}
}
}
return $links;
}
}
Comment | File | Size | Author |
---|---|---|---|
#1 | taxonomy.module.use_forum_links.patch | 1.14 KB | pfaocle |
Comments
Comment #1
pfaocleHere's a patch for the suggestion.
I like it. Showing the taxonomy information for different types of posts should be looked at, as these links need to be tailored for certain node types. It would be nice if a module for a particular node type could specify the link or callback to show different 'variants' of taxonomy listings.
Off the top of my head, this applies to:
Comment #2
magico CreditAttribution: magico commentedComment #3
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedSince drupal 5 we have a new hook hook todo such things nicely.. In drupal 6 we can (ab)use the menu system for this.
Comment #4
(not verified) CreditAttribution: commentedComment #5
Josh The Geek CreditAttribution: Josh The Geek commentedChange version.