- Issue created by @marcom2021
I'm trying to use a different navigation menu (horizonal and off canvas) for the homepage than on other pages. I was looking at the examples in the api file and used the following code:
function my_module_responsive_menu_off_canvas_menu_names_alter(&$menus) {
if (\Drupal::service('path.matcher')->isFrontPage()) {
$menus = 'frontpage-menu';
}
}
However, this changes the off canvas menu on ALL pages, not just the homepage.
I also used the following code to change the horizontal menu and that's not giving any issues, it seems to work fine.
function my_module_responsive_menu_horizontal_menu_name_alter(&$menu_name) {
if (\Drupal::service('path.matcher')->isFrontPage()) {
$menu_name = 'frontpage-menu';
}
}
So it's just the off canvas menu that's giving problems. Am I missing something or doing something wrong? I'm using the module on a Drupal 10 website, but also tested it on a Drupal 9 website which gave the same issue.
Active
4.4
Code