You are here

function content_taxonomy_terms_by_field in Content Taxonomy 5

Returns all term - node relation, optionally for a given parent

Parameters

Object Node: @param Integer Voc ID @param Integer TID of a Parent @param Integer depth of hierarchy to load

3 calls to content_taxonomy_terms_by_field()
content_taxonomy_activeselect_field_load in ./content_taxonomy_activeselect.module
adding of terms when node is loaded (called by content_taxonomy)
content_taxonomy_field in ./content_taxonomy.module
Implementation of hook_field().
content_taxonomy_views_field_terms_by_parent in ./content_taxonomy_views.module
Display all the terms for a given parent term

File

./content_taxonomy.module, line 218
Defines a field type for referencing a taxonomy term.

Code

function content_taxonomy_terms_by_field($node, $vid, $parent = NULL, $depth) {
  if (is_numeric($parent) && $depth == 1) {
    $result = db_query("SELECT n.tid FROM {term_hierarchy} h, {term_node} n WHERE\n      n.nid = %d AND n.tid = h.tid AND h.parent = %d", $node->nid, $parent);
    while ($data = db_fetch_array($result)) {
      $term = taxonomy_get_term($data["tid"]);
      $additions[$term->tid] = $term;
    }
    return $additions;
  }
  else {
    return taxonomy_node_get_terms_by_vocabulary($node->nid, $vid);
  }
}