Display class="active" when viewing matched category in categories list

  • 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...


    Code
    1. <ul>
    2.     <li><a href="#">Indoor</a></li>
    3.     <li><a href="#" class="active">Outdoor</a></li>
    4. </ul>



    Here's what I've got so far...


    Page:

    Code
    1. $cat = $_GET['cat'];
    2. PerchSystem::set_var('active', $cat);
    3. perch_categories([
    4. 'set' => 'attractions',
    5. 'template' => 'category_nav_pills.html',
    6. ]);


    Template:


    Many thanks


    Glen