The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Viewing Multiple Calendars in incrementing months

Labels

This Discussion is public

Notifications

Below is code I used to insert multiple calendars for the same view, but have increment months on them.  Insert this code into your php and use the shortcode for each calendar to display it.

Be sure to replace [id] with the id number of your view.

  1. First it gets the month and year from the GET (URL) or, if it's not set, it gets the current month and year.  It uses PHP's global variables to set the current month and year to whatever is selected in the first calendar (palm_cal1).
  2. palm_cal2 is the code for any subsequent calendars (just change the function and shortcode names.) It adds 1 (or 2 or 3 depending on your needs) to the global month, checks to see if the month is greater than 12 (or less than the global month) and increments the year.  I think this part needs some tweaking, but I ran out of time on this project.

Feel free to comment any tweaks.  I hope this helps!

//FIRST CALENDAR
function palm_cal1 ()
{
//SETUP: get date in URL or set it as today's date
if(isset($_GET['frmcal-month']))
{
$the_month = $_GET['frmcal-month'] ;
$the_year = $_GET['frmcal-year'];
}
else
{
$the_month = date("m");
$the_year = date("Y");
}
$GLOBALS['starting_month'] = $the_month;
$GLOBALS['starting_year']=$the_year;
//END SETUP

$the_calendar = FrmProDisplaysController::get_shortcode(array('id' => [id], 'frmcal-month'=>$the_month, 'frmcal-year' => $the_year));
return $the_calendar;
}
add_shortcode('palm1', 'palm_cal1');

//SECOND CALENDAR
function palm_cal2 ()
{    $the_month = $GLOBALS['starting_month']+1 ;
$the_year = $GLOBALS['starting_year'];
if(($the_month > 12) || ($the_month < $GLOBALS['starting_month']))
{$the_year = $the_year + 1;
if($the_month > 12){$the_month = $the_month-12;}
}
if ($the_month < 10) {$the_month=str_pad($the_month, 2,"0", STR_PAD_LEFT);}
echo $the_month; echo $the_year;
$the_calendar = FrmProDisplaysController::get_shortcode(array('id' => [id], 'frmcal-month'=>$the_month, 'frmcal-year' => $the_year));
return $the_calendar;
}
add_shortcode('palm2', 'palm_cal2');

Nice! Thanks for posting this publicly so others can benefit!

Discussion closed.