You are here

function nat_get_terms_by_vocabulary in Node Auto Term [NAT] 6.2

Same name and namespace in other branches
  1. 5 nat.module \nat_get_terms_by_vocabulary()
  2. 6 nat.module \nat_get_terms_by_vocabulary()
  3. 7.2 nat.module \nat_get_terms_by_vocabulary()
  4. 7 nat.module \nat_get_terms_by_vocabulary()

Retrieve the NAT terms associated with a node restricted by vocabulary.

Parameters

$nid: The node ID of the node whose NAT-terms are to be retrieved.

$vocabularies: An array of vocabulary IDs used to optionally retrict the retrieved terms to a defined set of vocabularies.

2 calls to nat_get_terms_by_vocabulary()
nat_get_children in ./nat.module
Retrieve all all the children of a node via its NAT association. Note: taxonomy_select_nodes is a rather resource hungry function.
nat_get_term in ./nat.module
Retrieve the first / single NAT term associated with a node optionally restricted by vocabulary.

File

./nat.module, line 283
NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.

Code

function nat_get_terms_by_vocabulary($nid, $vocabularies = array()) {
  $terms = nat_get_terms($nid);
  if (!empty($vocabularies)) {
    foreach ($terms as $tid => $term) {
      if (!in_array($term->vid, $vocabularies)) {
        unset($terms[$tid]);
      }
    }
  }
  return $terms;
}