Tuesday, 1 October 2013

Drupal Get All Child Term Items From a Taxonomy Term Based on Vocabulary

<?php
function taxonomy_get_children_all($tid, $vid = 0, $key = 'tid'){
  $c = taxonomy_get_children($tid, $vid, $key);
  $result = array();
  foreach ($c as $t => $d){
    $result[$t] = $d;
    $below = taxonomy_get_children_all($t, $vid, $key);
    if (!empty($below)) {
      foreach ($below as $nt => $nd){
        $result[$nt] = $nd;
      }
    }
  }
  return $result;
}
?>

No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.