You are here

function _taxonomy_menu_term_count in Taxonomy menu 8

Same name and namespace in other branches
  1. 6.3 taxonomy_menu.database.inc \_taxonomy_menu_term_count()
  2. 6.2 taxonomy_menu.database.inc \_taxonomy_menu_term_count()
  3. 7.2 taxonomy_menu.database.inc \_taxonomy_menu_term_count()
  4. 7 taxonomy_menu.database.inc \_taxonomy_menu_term_count()

@TODO Needs Updating since terms are related via node fields

used to get the count without children

Parameters

$tid:

1 call to _taxonomy_menu_term_count()
_taxonomy_menu_children_has_nodes in ./taxonomy_menu.module
Helper function to see if any of the children have any nodes.

File

./taxonomy_menu.database.inc, line 203
Database functions.

Code

function _taxonomy_menu_term_count($tid) {
  global $language;
  $result = db_select('taxonomy_index', 'tn');
  $result
    ->condition(db_and()
    ->condition('tid', $tid)
    ->condition(db_or()
    ->condition('n.language', $language->language)
    ->condition('n.language', Language::LANGCODE_NOT_SPECIFIED)));
  $result
    ->join('node', 'n', 'n.nid = tn.nid AND n.status = 1');
  $result
    ->addExpression('COUNT(n.nid)', 'term_count');
  $temp = $result
    ->execute();
  $temp = $temp
    ->fetchObject();
  return $temp->term_count;
}