Me again
I trying to display a simple navigation tab style using perch_categories(), which in itself works fine. However, so the user knows which category they are currently viewing I'm wanting to dynamically set the class class="active" on the active category link.
I have successfully set the category slug within the URL, retrieved the category slug and passed it into the template. The problem I am having is getting perch to create the class if the 2 match.
So for example, if the URL is domain.com?cat=outdoor the links would look like this...
Here's what I've got so far...
Page:
Template:
Code
- <perch:before>
- <div class="bg-light py-3">
- <div class="container">
- <ul class="nav nav-pills nav-fill">
- <li class="nav-item">
- <a class="nav-link mr-3" href="?cat=">Show All</a>
- </li>
- </perch:before>
- <li class="nav-item">
- <a class="nav-link mr-3<perch:if id="active" match="eg" value="{catSlug}"> active</perch:if>" href="?cat=<perch:category id="catSlug">"><perch:category id="catTitle"></a>
- </li>
- <perch:after>
- </ul>
- </div>
- </div>
- </perch:after>
Many thanks
Glen