function template_preprocess_we_megamenu_col in Drupal Mega Menu 8
Same name and namespace in other branches
- 8.x we_megamenu.module \template_preprocess_we_megamenu_col()
Prepare variables for we_megamenu_col.
Parameters
array $vars: Variables are declared in theme.
File
- ./
we_megamenu.module, line 501 - Drupal 8 Mega Menu Module.
Code
function template_preprocess_we_megamenu_col(array &$vars) {
$vars['attributes'] = new Attribute();
$vars['attributes']['class'] = [];
$vars['attributes']['class'][] = 'we-mega-menu-col';
$vars['attributes']['data-element-type'] = 'we-mega-menu-col';
if ($vars['item_config']) {
$col_items = $vars['item_config'];
$col_config = $col_items->col_config;
if (isset($col_config->block) && empty($col_config->block) && !empty($col_items->col_content)) {
$vars['subul'] = [
'#theme' => 'we_megamenu_subul',
'#items' => $vars['items'],
'#item_config' => $col_items->col_content,
'#section' => $vars['section'],
'#block_theme' => $vars['block_theme'],
'#menu_name' => $vars['menu_name'],
'#trail' => $vars['trail'],
];
}
if (isset($col_items->col_content->block_id)) {
$block_id = $col_items->col_content->block_id;
$title = isset($col_config->block_title) && $col_config->block_title == 1 ? TRUE : FALSE;
$vars['subul'] = [
'#theme' => 'we_megamenu_block',
'#block_content' => WeMegaMenuBuilder::renderBlock($block_id, $title, $vars['section']),
'#section' => $vars['section'],
'#block_theme' => $vars['block_theme'],
'#menu_name' => $vars['menu_name'],
'#trail' => $vars['trail'],
];
}
$vars['attributes']['class'][] = 'span' . $col_config->width;
$vars['attributes']['class'][] = isset($col_config->hidewhencollapse) && $col_config->hidewhencollapse && !empty($col_config->hidewhencollapse) ? 'hidden-collapse' : '';
$vars['attributes']['class'][] = isset($col_config->class) ? $col_config->class : '';
$vars['attributes']['data-width'] = $col_config->width;
$vars['attributes']['data-block'] = isset($col_config->block) ? $col_config->block : '';
$vars['attributes']['data-blocktitle'] = isset($col_config->block_title) ? $col_config->block_title : '';
$vars['attributes']['data-hidewhencollapse'] = isset($col_config->hidewhencollapse) ? $col_config->hidewhencollapse : '0';
$vars['attributes']['data-class'] = isset($col_config->class) ? $col_config->class : '';
$vars['attributes']['data-blocktitle'] = isset($col_config->block_title) ? $col_config->block_title : '';
}
else {
$vars['subul'] = [
'#theme' => 'we_megamenu_subul',
'#items' => $vars['items'],
'#section' => $vars['section'],
'#block_theme' => $vars['block_theme'],
'#menu_name' => $vars['menu_name'],
];
}
}