function taxonomy_get_related

You are here

4.6 taxonomy.module taxonomy_get_related($tid, $key = 'tid')
4.7 taxonomy.module taxonomy_get_related($tid, $key = 'tid')
5 taxonomy.module taxonomy_get_related($tid, $key = 'tid')
6 taxonomy.module taxonomy_get_related($tid, $key = 'tid')

Find all term objects related to a given term ID.

1 call to taxonomy_get_related()

File

modules/taxonomy.module, line 797
Enables the organization of content into categories.

Code

function taxonomy_get_related($tid, $key = 'tid') {
  if ($tid) {
    $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
    $related = array();
    while ($term = db_fetch_object($result)) {
      $related[$term->$key] = $term;
    }
    return $related;
  }
  else {
    return array();
  }
}