function template_preprocess_faq_questions_top in Frequently Asked Questions 7
Same name and namespace in other branches
- 8 includes/faq.questions_top.inc \template_preprocess_faq_questions_top()
- 6 includes/faq.questions_top.inc \template_preprocess_faq_questions_top()
- 7.2 includes/faq.questions_top.inc \template_preprocess_faq_questions_top()
Create the structure of the page, when the questions are to be shown on top.
Parameters
array &$variables: Array reference of arguments given to the theme() function.
Return value
array A variable holding the HTML formatted page.
File
- includes/
faq.questions_top.inc, line 17 - FAQ page callbacks for the "questions top" layouts.
Code
function template_preprocess_faq_questions_top(&$variables) {
$data = $variables['data'];
// Fetch configuration.
$teaser = variable_get('faq_use_teaser', FALSE);
$links = variable_get('faq_show_node_links', FALSE);
$disable_node_links = variable_get('faq_disable_node_links', FALSE);
// Configure labels.
$variables['question_label'] = '';
$variables['answer_label'] = '';
if (variable_get('faq_qa_mark', FALSE)) {
$variables['question_label'] = check_plain(variable_get('faq_question_label', "Q:"));
$variables['answer_label'] = check_plain(variable_get('faq_answer_label', "A:"));
}
// Configure "back to top" link.
$this_page = $_GET['q'];
$back_to_top = faq_init_back_to_top($this_page);
// Loop through results.
$questions = array();
$answers = array();
$key = 0;
foreach ($data as $node) {
$anchor = 'n' . $node->nid;
$questions[$key] = l($node->title, $this_page, array(
'fragment' => $anchor,
));
faq_view_question($answers[$key], $node, NULL, $anchor);
faq_view_answer($answers[$key], $node, $back_to_top, $teaser, $links);
$key++;
}
$variables['limit'] = $key;
$list_style = variable_get('faq_question_listing', 'ul');
$variables['list_style'] = $list_style;
$variables['use_teaser'] = $teaser;
$variables['questions'] = $questions;
$variables['answers'] = $answers;
$variables['questions_list'] = theme('item_list', array(
'items' => $questions,
'title' => NULL,
'type' => $list_style,
'attributes' => array(
"class" => "faq-ul-questions-top",
),
));
}