function faq_block_view in Frequently Asked Questions 7.2
Same name and namespace in other branches
- 7 faq.module \faq_block_view()
Implements hook_block_view().
File
- ./
faq.module, line 817 - 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_block_view($delta) {
static $vocabularies, $terms;
$block = array();
switch ($delta) {
case 'faq_categories':
if (module_exists('taxonomy')) {
if (!isset($terms)) {
$terms = array();
$vocabularies = taxonomy_get_vocabularies('faq');
$vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array()));
$vocabularies = array_diff_key($vocabularies, $vocab_omit);
foreach ($vocabularies as $vocab) {
foreach (taxonomy_get_tree($vocab->vid) as $term) {
if (faq_taxonomy_term_count_nodes($term->tid)) {
$terms[$term->name] = $term->tid;
}
}
}
}
if (count($terms) > 0) {
$block['subject'] = t('FAQ Categories');
$items = array();
foreach ($terms as $name => $tid) {
$items[] = l(faq_tt("taxonomy:term:{$tid}:name", $name), 'faq-page/' . $tid);
}
$list_style = variable_get('faq_category_listing', 'ul');
$block['content'] = theme('item_list', array(
'items' => $items,
'title' => NULL,
'type' => $list_style,
));
}
}
break;
}
return $block;
}