You are here

function theme_faq_random_highlights in Frequently Asked Questions 5

1 theme call to theme_faq_random_highlights()
faq_block in ./faq.module

File

./faq.module, line 1710

Code

function theme_faq_random_highlights($num = 5) {
  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid WHERE n.type='faq' AND n.status = 1 ORDER BY RAND()", "n", "nid"), 0, $num);
  $items = array();
  while ($node = db_fetch_object($result)) {
    $node = node_load(array(
      'nid' => $node->nid,
    ));
    $node = node_prepare($node);
    if (node_access("view", $node)) {
      $items[] = l($node->title, 'node/' . $node->nid);
    }
  }
  $list_style = variable_get('faq_question_listing', 'ul');
  $output = theme('item_list', $items, NULL, $list_style);
  $output .= l(t('All FAQs'), 'faq');
  return $output;
}