Forum

Thread tagged as: Question, Events

Nav item highlight depending on Event type (past or future)

I have two different listing pages of events: 1.Showing Today and 2.Coming Soon (based on Past and Future in the Events app).

I would like the nav to highlight 'Showing Today' or 'Coming Soon' depending on which listing you came from when you view an event. Probably easiest to see the website. You'll notice if you come from Coming Soon, the nav reverts to Showing Today. https://www.wheresgood.in

Here is my active element code in the item.html template. I'm guessing I need a way to tell the active class which event listing I came from? Not sure where to start...

<li<perch:if exists="current_page"> class="is-active"</perch:if>>
    <h3>
        <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
    </h3>
</li>
Mat Ranson

Mat Ranson 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You should be able to use PerchSystem::set_page() to tell which page you want Perch to treat the current page as.

Are you inferring that I could pass

<a href="<perch:events id="eventURL" />&type=comingsoon">

from the Coming Soon page, and then the event.php page can do

if ($pagetype=="comingsoon") {
    PerchSystem::set_page('/comingsoon.php');
} 

?

Feels a bit hacky (because I thought I might be able to do this with the navigation template) but it does the trick...

Drew McLellan

Drew McLellan 2638 points
Perch Support

There may be another way, but it's always a struggle to visualise how navigation should work for a dozen different people every day!

No sarcasm intended! You do a grand job :)