![Announcement icon Announcement icon](https://www.drupal.org/files/styles/grid-2-2x-square/public/announcements/drupal-evergreen-logo-280X280px%20%281%29_0.jpg?itok=PHpn6rCb)
This snippet lists all related terms of a taxonomy term in term view.
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.