You are here

function _fe_taxonomy_build_term_tree in Features Extra 6

Build a term tree.

1 call to _fe_taxonomy_build_term_tree()
_fe_taxonomy_get_terms in ./fe_taxonomy.module
Get all terms for a vocabulary.

File

./fe_taxonomy.module, line 412

Code

function _fe_taxonomy_build_term_tree($terms, $parent = 0) {
  static $tid_array = array();
  $tree = array();
  foreach ($terms as $tid => $term) {
    if (!in_array($tid, $tid_array) && array_key_exists($parent, $term['parent'])) {
      $tid_array[] = $tid;
      $item = array(
        'name' => $term['name'],
        'description' => $term['description'],
        'weight' => $term['weight'],
        'children' => _fe_taxonomy_build_term_tree($terms, $tid),
      );
      $tree[] = $item;
    }
  }
  return $tree;
}