function template_preprocess_menu__uk_subnav in UIkit Components 8.2
Implements template_preprocess_HOOK() for menu--uk-subnav.html.twig.
File
- includes/
preprocess.inc, line 84 - Set up variables to be placed within the template (.html.twig) files.
Code
function template_preprocess_menu__uk_subnav(&$variables) {
$menu_name = $variables['menu_name'];
$menu_style = UIkitComponents::getMenuStyle($menu_name);
$nav_width_classes = UIkitComponents::getNavWidthClasses($menu_name);
$attributes = new Attribute();
$wrapper_attributes = new Attribute();
if ($menu_style) {
$attributes
->addClass('uk-subnav');
if ($menu_style != 'uk-subnav') {
$attributes
->addClass($menu_style);
}
}
if ($nav_width_classes) {
$classes = explode(' ', $nav_width_classes);
foreach ($classes as $class) {
$wrapper_attributes
->addClass($class);
}
}
$variables['attributes'] = $attributes;
$variables['wrapper_attributes'] = $wrapper_attributes;
}