Commit 88f5d42e by Manzar Hussain

add active

parent 4b494370
......@@ -31,5 +31,35 @@ function envigo_form_search_block_form_alter(&$form, &$form_state) {
$form['actions']['submit']['#attributes']['class'][] = 'search-button';
}
function envigo_preprocess_menu(&$variables, $hook) {
if ($hook == 'menu') {
$current_path = \Drupal::request()->getRequestUri();
foreach ($variables['items'] as &$item) {
if ($item['in_active_trail']) {
if ($item['url']->toString() == $current_path) {
$item['is_active'] = TRUE;
} elseif (count($item['below'])) {
_themename_menu_process_submenu($item['below'], $current_path);
}
}
}
}
}
/**
* Set active and active-trail class for sub-menus recursively.
*/
function _envigo_menu_process_submenu(&$submenu, $current_path) {
foreach ($submenu as &$item) {
if ($item['in_active_trail']) {
if ($item['url']->toString() == $current_path) {
$item['is_active'] = TRUE;
} elseif (count($item['below'])) {
_themename_menu_process_submenu($item['below'], $current_path);
}
}
}
}
......@@ -43,9 +43,12 @@
'menu-item',
item.is_expanded ? 'dd_sub_menu',
item.is_collapsed ? 'menu-item--collapsed',
item.in_active_trail ? 'active_sb':'',
item.is_active ? 'active_sb',
]
%}
<li{{ item.attributes.addClass(classes) }}>
<div {% if item.below %} style="display: none;" {% endif %}> {{ link(item.title, item.url) }}</div>
{% if item.below %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment