1 taxonomy_term_depth_access.inc protected TaxonomyTermDepthLayoutAccess::getTermDepth($tid)

Gets the depth of a term.

Parameters

$tid: The taxonomy term ID

Return value

int: An integer representing how many levels deep your term is nested.

File

core/modules/taxonomy/layout/taxonomy_term_depth_access.inc, line 88
Plugin to provide access control based upon taxonomy term depth.

Class

TaxonomyTermDepthLayoutAccess
@file Plugin to provide access control based upon taxonomy term depth.

Code

protected function getTermDepth($tid) {
  $parent = db_query("SELECT parent FROM {taxonomy_term_hierarchy} WHERE tid = :tid", array(':tid' => $tid))->fetchField();
  if ($parent == 0) {
    return 1;
  }
  else {
    return 1 + $this->getTermDepth($parent);
  }
}