You are here

function _taxonomy_menu_term_too_deep in Taxonomy menu 7

Gets term depth from a tid.

Parameters

$tid: Taxonomy term ID.

$max_depth: Maximum depth.

Return value

bool Whether or not the term is too deep to include.

2 calls to _taxonomy_menu_term_too_deep()
_taxonomy_menu_taxonomy_termapi_helper in ./taxonomy_menu.module
Abstraction of hook_taxonomy_term_<operation>()
_taxonomy_menu_update_link_items in ./taxonomy_menu.module
Updates the menu items.

File

./taxonomy_menu.module, line 1286
Adds links to taxonomy terms into a menu.

Code

function _taxonomy_menu_term_too_deep($tid, $max_depth) {
  if ($max_depth) {
    $depth = 0;
    while ($parent = db_select('taxonomy_term_hierarchy', 't')
      ->condition('tid', $tid, '=')
      ->fields('t')
      ->execute()
      ->fetchAssoc()) {
      $depth++;
      $tid = $parent['parent'];
      if ($depth > $max_depth) {
        return TRUE;
      }
    }
  }
  return FALSE;
}