Skip to Content
Menu
This question has been flagged
2 Replies
2189 Views

Hi all,


Is it possible to make the parent item of a dropdown menu in the main navigation link to a specific page?


The display for the dropdown menu is set to: hover, so it won't interfere with the user if they want to select an item in said dropdown menu.


Example:

- Services -> link to /services can you make this a link? If yes, how?

-- Hardware and infrastructur --> links to a page (already works)

-- Hosting and ASP --> links to a page (already works)

Avatar
Discard
Best Answer

Hey, this is the workaround that I use

  1. Go to website editor and enter the edit mode
  2. Click theme tab and scroll down
  3. Under the Website Settings, click on "</body>" button beside the code injection field
  4. Add the following code

<script>
var links = document.querySelectorAll('a.nav-link.dropdown-toggle[href="#"] > span');
var MenuA = Array.from(links).find(span => span.textContent.trim() === 'Menu A');
if (MenuA) {

​var link = MenuA.parentElement;

​link.addEventListener('click', function(e) {

​e.preventDefault();

​window.location.href = '/menu-a';

​});

}

</script>

It is kind of hardcoded, but if you want another alternative, please refer to this link: https://www.odoo.com/en_US/forum/help-1/website-navbar-menu-links-with-sub-menu-200257

Avatar
Discard
Best Answer

That's a good question. 

I cannot believe this functionality is not included by default or nobody has posted a solution for such a simple question :(




Avatar
Discard

Hey Teodor, please refer to my answer

Related Posts Replies Views Activity
1
Aug 24
1111
2
Jan 23
2958
1
Jun 15
2554
0
Mar 15
3415
2
May 24
8787