Ok here is my dilemma. I’m trying to set up the navigation for when you click a category the category that you click is “Active” which has a different style. I have attached 2 images. One with the regular navigation and one with a HOVER state. I want when you click that category to stay in the hover “style”. Right now when i click on a category it reverts back to the regular navigation state. I know there must be a simple solution for this because i seen plenty if sites with “active” navigation. Hope someone can help me out with this.
I forgot to mention that i replaced the default navigation HTML with my own custom HTML & CSS. That would work if i had not replaced the default navigation HTML
The location of the file i edited is app/design/frontend/default/default/template/catalog/navigation/top.phtml
I am experiencing a similar issue - hope someone can help?
I have added a home link to the top nav -
<li class="<?php if (NOT SURE WHAT TO TEST FOR ) { echo "active"; } ?>"><a href="<?php echo $this->getUrl('')?>"><?php echo $this->__('HOME') ?></a></li>
I need to test if the user is on the homepage so I can set the class to active. Any ideas?
skrambo- You need to test if you are on the home page and if you are then echo the “active”.
jvalen- You have to add a class="active" to the <li> that has the current active category from your menu. In other words, using your example, if you are in the “customer service” category you need to make sure the menu has
likewise, for the “fragrance” category you’ll need to make that li have a class of “active” when you are in that category OR any of it’s subcategories.
<li class="<?php if (NOT SURE WHAT TO TEST FOR ) { echo "active"; } ?>"><a href="<?php echo $this->getUrl('')?>"><?php echo $this->__('HOME') ?></a></li>
If you see the code I have a echo to set the class to active based on a if statement. Just don’t know what the if statement should be.
The strpos function looks for something in a string. In this case it looks for the page link name ("contacts") in the URI, that you get through $_SERVER[’REQUEST_URI’]. If it finds it, it means the link is active.
It doesn’t work for the “home” link thou. It needs something else but I haven’t managed that yet. I hope someone can help me with that.
Hope it helps someone. This surely gave me an headache.