You are here

function template_preprocess_faq_questions_inline in Frequently Asked Questions 8

Same name and namespace in other branches
  1. 6 includes/faq.questions_inline.inc \template_preprocess_faq_questions_inline()
  2. 7.2 includes/faq.questions_inline.inc \template_preprocess_faq_questions_inline()
  3. 7 includes/faq.questions_inline.inc \template_preprocess_faq_questions_inline()

Create the FAQ page if set to show the questions inline.

Parameters

&$variables: Array reference of arguments given to the theme() function.

File

includes/faq.questions_inline.inc, line 20
FAQ page callbacks for the "questions inline" layouts.

Code

function template_preprocess_faq_questions_inline(&$variables) {
  $faq_settings = \Drupal::config('faq.settings');
  $data = $variables['data'];

  // Fetch configuration.
  $disable_node_links = $faq_settings
    ->get('disable_node_links');
  $teaser = $faq_settings
    ->get('use_teaser');
  $links = $faq_settings
    ->get('show_node_links');

  // Configure "back to top" link.
  $this_page = Url::fromRoute('<current>');
  $back_to_top = FaqViewer::initBackToTop($this_page);

  // Configure labels.
  $variables['question_label'] = '';
  $variables['answer_label'] = '';
  if ($faq_settings
    ->get('qa_mark')) {
    $variables['question_label'] = $faq_settings
      ->get('question_label');
    $variables['answer_label'] = $faq_settings
      ->get('answer_label');
  }
  $nodes = array();
  $count = 0;
  foreach ($data as $node) {
    $anchor = 'n' . $node
      ->id();
    FaqViewer::viewQuestion($nodes[$count], $node, NULL, $anchor);
    FaqViewer::viewAnswer($nodes[$count], $node, $teaser);
    $count++;
  }
  $variables['use_teaser'] = $teaser;
  $variables['nodes'] = $nodes;
}