You are here

function _taxonomy_menu_term_count in Taxonomy menu 7.2

Same name and namespace in other branches
  1. 8 taxonomy_menu.database.inc \_taxonomy_menu_term_count()
  2. 6.3 taxonomy_menu.database.inc \_taxonomy_menu_term_count()
  3. 6.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:

2 calls to _taxonomy_menu_term_count()
taxonomy_menu_translated_menu_link_alter in ./taxonomy_menu.module
Implements hook_translated_menu_link_alter().
_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 200
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_NONE)));
  $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;
}