Forum

Thread tagged as: Question, Runway, Events

Perch Calendar Category Next and Previous Months

Ok, so I'm using Perch Runway and I' almost there with my Calendar so I think it's best if you see the page I'm working on:

https://jw3.jolt-web.co.uk/events/

This is my Basic calendar which eventually will display all events from all categories. Using the next and previous arrows everything works fine.

I now want to filter events by their category and then subsequently navigate month my month. This works for the current month when you first click one of the category links above the calendar. However when I try an navigate to the next month in the calendar, the next and previous links are not right. I'm not sure what slug I'm trying to achieve for these buttons so if I knew that, I think would be halfway there.

Any help by clever people would be appreciated.

Richard Lowe

Richard Lowe 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us what code you're using for those links?

Richard Lowe

Richard Lowe 0 points
Registered Developer

Right Now it's this, but I've tried loads of things


<h2 class="calendarmonth"><perch:events id="selected_month" format="%B %Y" /></h2> <ul class="calendar-nav"> <li><a class="paging-prev" href="<perch:if id="catSlug" match="eq" value="{current_category}"></perch:if>?d=<perch:events id="prev_month" format="Y-m" />"> <perch:events id="prev_month" format="%b %Y" /></a></li> <li><a href="<perch:if id="catSlug" match="eq" value="{current_category}"></perch:if>?d=<perch:events id="selected_month" format="Y-m" />"><perch:events id="selected_month" format="%b %Y" /></a></li> <li><a class="paging-next" href="<perch:if id="catSlug" match="eq" value="{current_category}"></perch:if>?d=<perch:events id="next_month" format="Y-m" />"><perch:events id="next_month" format="%b %Y" /> </a></li> </ul> <perch:if exists="body"> <ul class="calendar"> <perch:events id="body" encode="false" /> </ul> <perch:else /> </perch:if> <perch:showall />
Drew McLellan

Drew McLellan 2638 points
Perch Support

The in-built pagination won't slice the list by date. It just cuts it up by the per-page limit.

To show monthly listings you're going to need to filter by month and year. Your previous and next links will therefore need to link to the previous or next month.

That should be easy to find in PHP with e.g.

strtotime('2016-07-18 +1 MONTH');
Richard Lowe

Richard Lowe 0 points
Registered Developer

I'll probably just create separate pages for each category. Thanks anyway!