function _term_depth

Find the depth of a term.

1 call to _term_depth()
term_depth_term_depth_ctools_access_check in term_depth/plugins/access/term_depth.inc
Check for access.

File

term_depth/plugins/access/term_depth.inc, line 120

Code

function _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 + _term_depth($parent);
        }
    }
    return $depths[$tid];
}