You are here

function faq_highlights_block in Frequently Asked Questions 6

Same name and namespace in other branches
  1. 5.2 faq.module \faq_highlights_block()

Create the HTML output for the Recent 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 Recent FAQs.

1 call to faq_highlights_block()
faq_block in ./faq.module
Implements hook_block().

File

./faq.module, line 848
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_highlights_block($num = 5) {
  $disable_node_links = variable_get('faq_disable_node_links', FALSE);
  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY n.created DESC", "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[] = l($node->question, 'faq', array(
          'fragment' => 'n' . $node->nid,
        ));
      }
      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;
}