nav-selected hickups when two pages have similar names
Permalink
(probably a bug: when one page name contains another page's name, both are "nav-selected" instead of just the one that is actually active.)
Hi everyone,
I discovered a strange behaviour of the autonav block.
I am using version 5.5.2.1.
Say, I have three pages,
- page
- test
- test2
When I select "page" and "test", everything works fine - the page is displayed, and the correct <li> and <a> tags have the "nav-selected" class.
When I select "test2", however, both "test2" and "test" are displayed "nav-selected" in the autonav block.
This also works with something like "customer" and "customer's project".
This behaviour is not dependent on the order in which these appear in the site map.
Apparently, it always comes up when one page name fully contains the other.
Obviously, I want this to go away. :-)
Has anyone an idea how to make it?
Many thanks for any advice!
Hi everyone,
I discovered a strange behaviour of the autonav block.
I am using version 5.5.2.1.
Say, I have three pages,
- page
- test
- test2
When I select "page" and "test", everything works fine - the page is displayed, and the correct <li> and <a> tags have the "nav-selected" class.
When I select "test2", however, both "test2" and "test" are displayed "nav-selected" in the autonav block.
This also works with something like "customer" and "customer's project".
This behaviour is not dependent on the order in which these appear in the site map.
Apparently, it always comes up when one page name fully contains the other.
Obviously, I want this to go away. :-)
Has anyone an idea how to make it?
Many thanks for any advice!
Hi mckoenig,
thanks for your answer.
Maybe I didn't get the thought across correctly – the strange behaviour does not exist when I navigate to "test", but when I navigate to "test2" (both of which are on the same level). If I do, both "test2" (correctly) and "test" (incorrectly) have the "nav-selected" class.
I didn't alter the autonav code. And I am also confused as to why this would happen, because I also saw it only checks for the ID.
Nonetheless, the problem persists...
thanks for your answer.
Maybe I didn't get the thought across correctly – the strange behaviour does not exist when I navigate to "test", but when I navigate to "test2" (both of which are on the same level). If I do, both "test2" (correctly) and "test" (incorrectly) have the "nav-selected" class.
I didn't alter the autonav code. And I am also confused as to why this would happen, because I also saw it only checks for the ID.
Nonetheless, the problem persists...
Still can't confirm. If I navigate to "test2" in my setup the source looks like this:
<nav> <ul class="nav"> <li><a href="/" >Home</a></li> <li><a href="/test/" >test</a></li> <li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" href="/test2/">test2</a></li> </ul> </nav>
This is strange.
[I had changed the autonav controller to be able to display four levels of menu, but even with the standard autonav block, this problem persists.]
As a short-term workaround, I renamed the address and the problem disappeared.
But I am still rather confused about this.
[I had changed the autonav controller to be able to display four levels of menu, but even with the standard autonav block, this problem persists.]
As a short-term workaround, I renamed the address and the problem disappeared.
But I am still rather confused about this.
<ul class="nav-header"> <li class="nav-selected first"><a href="/test/">test</a></li> <li class="nav-selected "><a href="/test2/" class="nav-selected">test2</a></li> </ul>
The code you quoted doesn't seem to be generated by the original autonav block as the <ul> has the class "nav-header" which isn't set in the original code.
Have you tried reproducing this with a clean install, just for testing purposes?
Have you tried reproducing this with a clean install, just for testing purposes?
See default autonav view.php, around line 67:
Have you modified the view.php of the autonav controller in any way? Are the pages in your setup on the same level? Because if they are underneath each other it might be the "nav-path-selected" class you are talking about which indicates the parents to the open page.