function faq_taxonomy_term_count_nodes in Frequently Asked Questions 7
Same name and namespace in other branches
- 7.2 faq.module \faq_taxonomy_term_count_nodes()
Count number of nodes for a term and its children.
11 calls to faq_taxonomy_term_count_nodes()
- faq_block_view in ./
faq.module - Implements hook_block_view().
- faq_get_child_categories_faqs in ./
faq.module - Helper function for retrieving the sub-categories faqs.
- faq_order_settings_form in ./
faq.admin.inc - Define the elements for the FAQ Settings page - order tab.
- faq_page in ./
faq.module - Function to display the faq page.
- faq_view_child_category_headers in ./
faq.module - Helper function to setup the list of sub-categories for the header.
File
- ./
faq.module, line 1748 - The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.
Code
function faq_taxonomy_term_count_nodes($tid) {
static $count;
if (!isset($count) || !isset($count[$tid])) {
$query = db_select('node', 'n')
->fields('n', array(
'nid',
))
->addTag('node_access');
$query
->join('taxonomy_index', 'ti', 'n.nid = ti.nid');
$query
->condition('n.type', 'faq')
->condition('n.status', 1)
->condition('ti.tid', $tid);
$count[$tid] = $query
->countQuery()
->execute()
->fetchField();
}
$children_count = 0;
foreach (faq_taxonomy_term_children($tid) as $child_term) {
$children_count += faq_taxonomy_term_count_nodes($child_term);
}
return $count[$tid] + $children_count;
}