Forum
Pagination by Month
I created a basic list of events in runway. Works perfectly and it's pulling the events for the current month without issue.
My question: How do I setup paginate to create "previous month" and "next month" links?
I tried looking at the old Events.app for pointers or clues, but it appears the functionality I'm after is in the app itself.
// Current Month's Events
perch_content_custom('Events', array(
'template' => 'calendar/calendar.html',
'sort' => 'eventDateTime',
'sort-order' => 'ASC',
'filter' => 'eventDateTime',
'match' => 'eqbetween',
'value' => date('Y-m-01 00:00:00, Y-m-31 23:59:59'),
));
// Grab previous month for layout variable
$month_prev = date('m', strtotime('-1 month'));
// Set layout variable
perch_layout('events.above.interior', [
'event_month_prev' => $month_prev
]);
// Previous Month's Events
perch_content_custom('Events', array(
'template' => 'calendar/calendar_previous_button.html',
'sort' => 'eventDateTime',
'sort-order' => 'ASC',
'filter' => 'eventDateTime',
'match' => 'eqbetween',
'value' => date('Y-'$month_prev'-01 00:00:00, Y-'$month_prev'-31 23:59:59'),
));
Thanks for showing me the proper format. Works and pull the previous month. I guess this isn't going to work for
$month_next
which wouldn't account for the year changing in December. What's the proper way in that case?For paging through the actual events I used code like this:
Real Question: How do you do the same as above, but for a month at a time, and not be dependant on the event itself using
_order
so you can view the entire previous month's dates?strtotime()
deals with that as you have it. Include the year too.Great that works perfect. Now I have current month, previous month, next month all working on same page.
While I am on the current month, how can navigate to previous month? (or next, if dates allow)
I only want content for one month at a time.
I'm afraid I don't have the capacity to build this solution for you one question at a time! These are general PHP logic questions, so I'm sure there are much better places to get help.
Thank you for getting me this far. I appreciate it Drew. :)
Now that you can display current, next and previous month's on the page, I would probably approach this with PHP if statements that check for query strings in the URL. And add Next and Previous Month links based on the URL structure you choose.