function taxo_faceted_navigation_get_subnodes in Taxonomy Facets 7
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 taxo_faceted_navigation_get_subnodes()
- _taxo_faceted_navigation_get_menu_tree in ./
taxo_faceted_navigation.module - Helper function for taxo_faceted_navigation_get_menu_tree.
File
- ./
taxo_faceted_navigation.module, line 939 - Taxo Faceted Navigation module code.
Code
function taxo_faceted_navigation_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;
}