You are here

function taxonomy_facets_get_subnodes in Taxonomy Facets 7.2

Same name and namespace in other branches
  1. 7.3 taxonomy_facets.module \taxonomy_facets_get_subnodes()

Examine term and test for any children nodes.

Parameters

integer $vid: Vocabulary Id.

integer $tid: Term id

Return value

boolean True if there are children taxonomy terms underneath given term.

1 call to taxonomy_facets_get_subnodes()
taxonomy_facets_display_meny_item_check in ./taxonomy_facets.module
When building menu tree we check if we want to display a menu item depending on various user preferences

File

./taxonomy_facets.module, line 1014
Taxo Faceted Navigation module code.

Code

function taxonomy_facets_get_subnodes($vid, $tid) {

  // First check if term has nodes.
  $result = db_query('SELECT nid FROM {taxonomy_index} WHERE tid = :tid', array(
    ':tid' => $tid,
  ));
  if ($result
    ->rowCount()) {
    return TRUE;
  }
  else {

    // Get all children and check each child for nodes.
    $children = taxonomy_get_tree($vid, $tid);
    foreach ($children as $child) {
      $result = db_query('SELECT nid FROM {taxonomy_index} WHERE tid = :tid', array(
        ':tid' => $child->tid,
      ));
      if ($result
        ->rowCount()) {
        return TRUE;
      }
    }
  }
  return FALSE;
}