You are here

function synonyms_taxonomy_term_is_child_of in Synonyms 7

Check whether a taxonomy term $tid is a child of a taxonomy term $parent_tid.

Supportive function, used throughout this module for parent constrains.

Parameters

int $tid: {taxonomy_term}.tid of the term that is tested for being a child of the $parent_tid term

int $parent_tid: {taxonomy_term}.tid of the term that is tested for being parent of the $tid term

Return value

bool Whether $tid is a child of $parent_tid

1 call to synonyms_taxonomy_term_is_child_of()
synonyms_get_term_by_synonym in ./synonyms.module
Try to find a term by its name or synonym.

File

./synonyms.module, line 1247
Provide synonyms feature for Drupal entities.

Code

function synonyms_taxonomy_term_is_child_of($tid, $parent_tid) {
  $term_parents = taxonomy_get_parents_all($tid);

  // Dropping out the term itself from its array of parents.
  array_shift($term_parents);
  foreach ($term_parents as $term_parent) {
    if ($term_parent->tid == $parent_tid) {
      return TRUE;
    }
  }
  return FALSE;
}