Last active
December 12, 2015 03:28
-
-
Save greenboyroy/4706619 to your computer and use it in GitHub Desktop.
Just a quick snippet for getting multiple calendar months (in this case two) to display using Events in Perch. Please feel free to use, abuse and improve, obviously.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="calendars"> | |
<?php | |
$opts = array( | |
'past-events'=>false | |
); | |
// this months calendar | |
perch_events_calendar($opts); | |
// if we have a date in the url, use it, otherwise, get today's date | |
if ( isset( $_GET['d'] ) && !empty( $_GET['d'] ) ) { | |
$date = $_GET['d']; | |
} else { | |
$date = date('Y-m'); | |
}; | |
// add a month to the date we used | |
$newdate = strtotime(date("Y-m-d", strtotime($date)) . " +1 month"); | |
// trick perch as to the actual date. | |
$_GET['d'] = date("Y-m", $newdate); | |
//next months calendar | |
perch_events_calendar($opts);?> | |
</div><!-- #calendars --> | |
<?php | |
//put the buttons under both calendars, rather than twice, using another template. | |
$btn_opts = array ( | |
'past-events'=>false, | |
'calendar-template'=>'events/calendar/calendar-buttons.html' | |
); | |
// reset the date | |
$_GET['d'] = $date; | |
// the navigation buttons | |
perch_events_calendar($btn_opts); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment