You are here

function content_taxonomy_get_terms in Content Taxonomy 7

Returns an array of terms that can be used in an options list.

By default taxonomy_get_tree is used to retrieve the list of terms, but an alteration via hook_content_taxonomy_tree_callback_alter() is possible. It is important that any provided tree callback must have the same function signature as hook_content_taxonomy_tree_callback_alter(). For example this hook can be used to exchange the callback with a language specific tree function.

Although we could change the options list callback via the field definitions, it is easier to do this via the alteration hook provided by this function.

Parameters

$field: The term reference field info array.

$vocabulary: The vocabulary object for which the term list should be retrieved. One field can have multiple vocabularies attached, which leads to multiple invocations of this function.

$parent: The parent term id. Use 0 for the root level.

$max_depth: The maximum depth. Use NULL for non limitation.

Return value

array

2 calls to content_taxonomy_get_terms()
content_taxonomy_allowed_values in ./content_taxonomy.module
Returns the set of valid terms for a taxonomy field. Extends taxonomy_allowed_values() with the tree depth option.
content_taxonomy_allowed_values_opt_groups in ./content_taxonomy.module
Helper function for generating opt groups.

File

./content_taxonomy.module, line 118

Code

function content_taxonomy_get_terms($field, $vocabulary, $parent, $max_depth) {
  $terms = array();
  $tree_callback = 'taxonomy_get_tree';
  drupal_alter('content_taxonomy_tree_callback', $tree_callback, $field, $vocabulary);
  if (function_exists($tree_callback)) {
    $terms = $tree_callback($vocabulary->vid, $parent, $max_depth, FALSE);
  }
  return $terms;
}