function template_preprocess_faq_new_page in Frequently Asked Questions 8
Same name and namespace in other branches
- 6 includes/faq.new_page.inc \template_preprocess_faq_new_page()
- 7.2 includes/faq.new_page.inc \template_preprocess_faq_new_page()
- 7 includes/faq.new_page.inc \template_preprocess_faq_new_page()
Create FAQ page if set to show the answer in a new page.
Parameters
&$variables: Array reference of arguments given to the theme() function.
File
- includes/
faq.new_page.inc, line 20 - FAQ page callbacks for the "new page" layouts.
Code
function template_preprocess_faq_new_page(&$variables) {
$faq_settings = \Drupal::config('faq.settings');
$items = array();
$data = $variables['data'];
foreach ($data as $node) {
$node_id = $node
->id();
$items[] = Link::fromTextAndUrl($node
->getTitle(), $url = $node
->toUrl())
->toString();
}
$list_style = $faq_settings
->get('question_listing');
$variables['list_style'] = $list_style;
$variables['list_items'] = $items;
$item_list = array(
'#theme' => 'item_list',
'#title' => NULL,
'#list_type' => $list_style,
'#items' => $items,
);
$variables['list'] = new FormattableMarkup(\Drupal::service('renderer')
->render($item_list), []);
}