You are here

function taxo_faceted_navigation_taxonomy_term_get_siblings in Taxonomy Facets 7

Get siblings of taxonomy term.

Utility function that returns first siblings of a given taxonomy term.

Parameters

integer $tid: Term id of the term we for which we need to return siblings.

integer $vid: (optional) Vocabulary id. Default is NULL.

Return value

array Array of term sibilings.

File

./taxo_faceted_navigation.module, line 680
Taxo Faceted Navigation module code.

Code

function taxo_faceted_navigation_taxonomy_term_get_siblings($tid, $vid = NULL) {

  // Get term parent, if no parent it means its first level,
  // in which case just get first level terms for vocabulary.
  $parent = taxo_faceted_navigation_taxonomy_term_get_parent($tid);
  if ($parent) {

    // There is parent, so get all children of a parent.
    $siblings = taxonomy_get_children($parent, $vid = 0);
  }
  else {

    // No parent so it means its first level, get first level children,
    // i.e siblings.
    $siblings = taxonomy_get_tree($vid, 0, 1, FALSE);
  }
  return $siblings;
}