NavMenu - set class via getCollectionName()

Permalink
I'm trying to configure a nav menu and need to set the active menu hilite based upon current page. Any coders out there who could help? I need to figure out the If statement to do this. Here's sample of two items. I need the "current" class set depending upon page.

<li id="current"><span><?php echo $c->getCollectionName() ?></span></li>
          <li><a href="<?php echo $this->url('/beliefs')?>"><span>Beliefs</span></a></li>


Thanks
-Mark

marxion
 
ScottC replied on at Permalink Reply
ScottC
Hi, I am not quite sure what you mean. For a nav selected item in the default out of the box Concrete5 installation when I click "Examples" I am taken to the example page. When I look at the html code for the page I see this:

<li class="nav-selected "><a class="nav-selected" href="/index.php/examples/">Examples</a></li>


I am sure I am missing something, but couldn't you just tweak your css code to look for the nav-selected class?
marxion replied on at Permalink Reply
marxion
I am not using the Header Nav function for this menu. It is coded in my template. CSS ID="Current" hilites the active menu name for the current page. I don't want to have to create a menu for every page to use the "Current" class. I tried creating a "nav-selected" class but no luck. This is probably not that difficult I'm just not a seasoned coder....Thanks for your help.

The idea is if page = current then the li CSS ID="Current" for that menu item else not.