function template_preprocess_faq_hide_answer in Frequently Asked Questions 8
Same name and namespace in other branches
- 6 includes/faq.hide_answer.inc \template_preprocess_faq_hide_answer()
- 7.2 includes/faq.hide_answer.inc \template_preprocess_faq_hide_answer()
- 7 includes/faq.hide_answer.inc \template_preprocess_faq_hide_answer()
Create FAQ page if set to show/hide answer when question is clicked.
Parameters
&$variables: Array reference of arguments given to the theme() function.
File
- includes/
faq.hide_answer.inc, line 20 - FAQ page callbacks for the "hide answer" layouts.
Code
function template_preprocess_faq_hide_answer(&$variables) {
$faq_settings = \Drupal::config('faq.settings');
$data = $variables['data'];
$this_page = Url::fromRoute('<current>');
// Fetch configuration.
$teaser = $faq_settings
->get('use_teaser');
$nodes = array();
foreach ($data as $index => $node) {
$anchor = 'n' . $node
->id();
FaqViewer::viewQuestion($nodes[$index], $node, $this_page, $anchor);
FaqViewer::viewAnswer($nodes[$index], $node, $teaser);
}
$variables['use_teaser'] = $teaser;
$variables['nodes'] = $nodes;
}