You are here

function template_preprocess_simple_mega_menu in Simple Mega Menu 2.0.x

Same name and namespace in other branches
  1. 8 simple_mega_menu.page.inc \template_preprocess_simple_mega_menu()

Prepares variables for Simple mega menu templates.

Default template: simple_mega_menu.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An associative array containing the user information and any
  • attributes: HTML attributes for the containing element.

File

./simple_mega_menu.page.inc, line 22
Contains simple_mega_menu.page.inc.

Code

function template_preprocess_simple_mega_menu(array &$variables) {

  // Fetch SimpleMegaMenu Entity Object.

  /** @var \Drupal\simple_megamenu\Entity\SimpleMegaMenu $simple_mega_menu */
  $simple_mega_menu = $variables['elements']['#simple_mega_menu'];
  $variables['view_mode'] = $variables['elements']['#view_mode'];
  $variables['bundle'] = $simple_mega_menu
    ->bundle();
  $variables['simple_mega_menu'] = $simple_mega_menu;

  // Helpful $content variable for templates.
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}