You are here

function _path_breadcrumbs_term_depth in Path Breadcrumbs 7.3

Find the depth of a term.

1 call to _path_breadcrumbs_term_depth()
path_breadcrumbs_term_depth_ctools_access_check in plugins/access/path_breadcrumbs_term_depth.inc
Check for access.

File

plugins/access/path_breadcrumbs_term_depth.inc, line 101
Plugin to provide access control based on term depth.

Code

function _path_breadcrumbs_term_depth($tid) {
  static $depths = array();
  if (!isset($depths[$tid])) {
    $parent = db_select('taxonomy_term_hierarchy', 'th')
      ->fields('th', array(
      'parent',
    ))
      ->condition('tid', $tid)
      ->execute()
      ->fetchField();
    if ($parent == 0) {
      $depths[$tid] = 1;
    }
    else {
      $depths[$tid] = 1 + _path_breadcrumbs_term_depth($parent);
    }
  }
  return $depths[$tid];
}