function template_preprocess_we_megamenu_submenu in Drupal Mega Menu 8
Same name and namespace in other branches
- 8.x we_megamenu.module \template_preprocess_we_megamenu_submenu()
Prepare variables for we_megamenu_submenu.
Parameters
array $vars: Variables are declared in theme.
File
- ./
we_megamenu.module, line 416 - Drupal 8 Mega Menu Module.
Code
function template_preprocess_we_megamenu_submenu(array &$vars) {
$item_config = $vars['item_config'];
if (isset($item_config->rows_content) && !empty($item_config->rows_content)) {
$rows_content = $item_config->rows_content;
foreach ($rows_content as $key_row => $row) {
$vars['row'][] = [
'#theme' => 'we_megamenu_row',
'#items' => $vars['items'],
'#item_config' => $row,
'#section' => $vars['section'],
'#block_theme' => $vars['block_theme'],
'#menu_name' => $vars['menu_name'],
'#trail' => $vars['trail'],
];
}
}
else {
$vars['row'] = [
'#theme' => 'we_megamenu_row',
'#items' => $vars['items'],
'#section' => $vars['section'],
'#block_theme' => $vars['block_theme'],
'#menu_name' => $vars['menu_name'],
'#trail' => $vars['trail'],
];
}
$submenu_config = isset($item_config->submenu_config) ? $item_config->submenu_config : [];
$vars['attributes'] = new Attribute();
$vars['attributes']['class'] = [];
$vars['attributes']['class'][] = 'we-mega-menu-submenu';
$vars['attributes']['class'][] = isset($submenu_config->class) ? $submenu_config->class : '';
$vars['attributes']['data-element-type'] = 'we-mega-menu-submenu';
$vars['attributes']['data-submenu-width'] = isset($submenu_config->width) ? $submenu_config->width : '';
$vars['attributes']['data-class'] = isset($submenu_config->class) ? $submenu_config->class : '';
$vars['attributes']['style'] = isset($submenu_config->width) ? 'width: ' . $submenu_config->width . 'px' : '';
}