function faq_random_highlights_block in Frequently Asked Questions 5.2
Same name and namespace in other branches
- 6 faq.module \faq_random_highlights_block()
Create the HTML output for the Random FAQs block.
Parameters
$num: The default value is 5; determines the number of FAQ entries to be shown.
Return value
The HTML-formatted code displaying the Random FAQs.
1 call to faq_random_highlights_block()
- faq_block in ./
faq.module - Implementation of hook_block().
File
- ./
faq.module, line 1240 - 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_random_highlights_block($num = 5) {
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
$result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY RAND()", "n", "nid"), 0, $num);
$items = array();
while ($row = db_fetch_object($result)) {
$node = node_load(array(
'nid' => $row->nid,
));
$node = node_prepare($node);
if (node_access("view", $node)) {
if ($disable_node_links) {
$items[] = check_plain($node->question);
}
else {
$items[] = l($node->question, 'node/' . $node->nid);
}
}
}
$list_style = variable_get('faq_question_listing', 'ul');
$output = theme('item_list', $items, NULL, $list_style);
$output .= '<div class="faq-all-faqs-link">' . l(t('All FAQs'), 'faq') . '</div>';
return $output;
}