You are here

function faq_preprocess_page in Frequently Asked Questions 8

Same name and namespace in other branches
  1. 6 faq.module \faq_preprocess_page()
  2. 7.2 faq.module \faq_preprocess_page()
  3. 7 faq.module \faq_preprocess_page()

Implements template_preprocess_page().

Overrider breadcrumbs for faq pages.

File

./faq.module, line 187
The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.

Code

function faq_preprocess_page(&$variables) {
  $faq_settings = \Drupal::config('faq.settings');
  $use_categories = $faq_settings
    ->get('use_categories');
  $route_match = \Drupal::service('current_route_match');
  $tid = $route_match
    ->getRawParameter('tid');
  if (FaqHelper::searchInArgs('faq-page') && $use_categories && is_numeric($tid) && ($current_term = Term::load($tid))) {
    $breadcrumb = FaqHelper::setFaqBreadcrumb($current_term);
    if (!empty($breadcrumb)) {
      $variables['breadcrumb']['#breadcrumb'] = $breadcrumb;
    }
  }
}