Tab Menu / Posts /

Forcing non-active for all menu items if none of their links are matching the current page URL

0

Some of my page URLs are not included in the tab menu links. When I navigate to that page through another navigation in the footer of the page, I found the first tab menu item "HOME" is active.  For the user it is confusing to see an active main menu tab like "HOME" while being on a no "home" content.

How can I remove the "active" class if none of the main tab menu items are shown in the content part of the site?

Michael  10 years ago   viewed: 8959    

3 Answers

0

If none of the tab menu items(either in the main level or in the sub-level) are the current page URL, the tab menu will fail to find any matching items, and then it will by default take the first main item as active (yes I admit it is kind of stupid, but Menucool has to stick to it. It is quite common that a page URL may contain variable queries and hashes, but it is still the same page. So this non-precise matching is often required).

Workaround:

You can create a dummy menu group within the tab menu markup, and style it to be invisible. Make your "excluded" page URLs be included in the group.

1. If you don't need to show the sub-menu bar:

<li style="display:none;"> invisible group <ul> <li><a href="?51"></a></li> <li><a href="?52"></a></li> <li><a href="?53"></a></li> </ul> </li>

2. Or, if you need to show the sub-menu bar:

<li> <a href="?dummy" style="display:none;">dummy</a> <ul> <li><a href="?51" style="visibility:hidden;"></a></li> <li><a href="?52" style="visibility:hidden;"></a></li> <li><a href="?53" style="visibility:hidden;"></a></li> </ul> </li>
Milo   10 years ago
0
Is there no possibility to customize the script?
Shouldn't that be a simple if clause?

If (no menu item matches )
    don't add any Active classes
Michael
  10 years ago
0
Thanks for your good suggestion. We are considering rewrite the script in its next release. Currently we are tied up with other stuff, and don't have the schedule yet.
Milo   10 years ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question:
    • If your question is related to the Tab Menu, click:

      Ask new question: Tab Menu
    • Otherwise navigate to one of the following forum categories, and post your question there.

      ##