- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Menu option "active-branch"
SOLVENov 16, 2020 7:39 AM
I have one menu in this blog:
I need to mark the "All" option as active when we access the site and then deactivate it when we access any of the other options.
Thank you very much and best regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Nov 16, 2020 1:32 PM - edited Nov 17, 2020 7:43 AM
Hi @jmgonzalez67 !
The ideal way to do this would be to edit your current function that does this to accomodate the All button too!
If for any reason you can't do that one quick way of doing this would be by using the following code in your blog listing template, in the Additional markup before </body> box on the right pane in the design manager.
<script>
{% if content.absolute_url == "https://blog.strands.com" %}
document.querySelector('#hs_menu_wrapper_module_1603711816926175_').children[1].children[0].className += "active active-branch";
{% endif %}
</script>
It's important to add this in the "before </body>" tag, or otherwise to use a function that waits for the DOM elements to load, otherwise onload the styling would be overwritten.
After checking your page I saw that the styling is applied by appending the active active-branch to your class - there's probably a few better ways of doing this, but that should work for now!
Edit: as per @piersg reply below they list an ideal way to do this if you're editing your blog template or creating a new one using the blog_tags function - the fix above is specifically used as the set up uses a menu and no blog tag functions which I should have mentioned 🙂 Thanks for the advice @piersg !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content