List related terms
Last modified: April 22, 2008 - 11:04
This snippet lists all related terms of a taxonomy term in term view.
<?php
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && is_null(arg(3))) {
$tid = (int)arg(2);
$result = db_query(db_rewrite_sql('SELECT tid, name FROM {term_relation} INNER JOIN {term_data} ON (tid1 = tid OR tid2 = tid) WHERE (tid1 = %d OR tid2 = %d) AND tid != %d ORDER BY weight, name', '{term_relation}', 'tid'), $tid, $tid, $tid);
$output = '';
while ($term = db_fetch_object($result))
{
$output .= ((!empty($output)) ? ', ' : '') . l($term->name, "taxonomy/term/$term->tid");
}
return $output;
}
?>This block was designed to be viewed in the content region. Change ((!empty($output)) ? ', ' : '') to ((!empty($output)) ? '<br />' : '') if you want to use it in a sidebar.

Drupal 5 version please?
Drupal 5 version please? Thanks in advance, greetings, Martijn