SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: thomsalva on December 01, 2013, 04:37:34 AM

Title: Previous / Next in calendar
Post by: thomsalva on December 01, 2013, 04:37:34 AM
Is it possible to create a block for the calendar with the Previous / Next links for the months in that calendar block ?
Title: Re: Previous / Next in calendar
Post by: thomsalva on December 02, 2013, 02:33:38 AM
Oh, so many views but no one to help  :(

I've found this code online, and altered it to fit my needs. Just c/p it in the php block

Code: [Select]
/* date settings */
$month = (int) (isset($_GET['month']) ? $_GET['month'] : date('m'));
$year = (int)  (isset($_GET['year']) ? $_GET['year'] : date('Y'));
/* select month control */
$select_month_control ='<select name="month" id="action=calendar;month">';
for($x = 1; $x <= 12; $x++) {
$select_month_control.= '<option value="'.$x.'"'.($x != $month ? '' : ' selected="selected"').'>'.date('F',mktime(0,0,0,$x,1,$year)).'</option>';
}
$select_month_control.= '</select>';

/* select year control */
$year_range = 7;
$select_year_control = '<select name="year" id="year">';
for($x = ($year-floor($year_range/2)); $x <= ($year+floor($year_range/2)); $x++) {
$select_year_control.= '<option value="'.$x.'"'.($x != $year ? '' : ' selected="selected"').'>'.$x.'</option>';
}
$select_year_control.= '</select>';


/* "previous month" control */
$previous_month_link = '<a href="?action=calendar;month='.($month != 1 ? $month - 1 : 12).'&year='.($month != 1 ? $year : $year - 1).'" class="control"><< Previous Month</a>';

/* "next month" control */
$next_month_link = '<a href="?action=calendar;month='.($month != 12 ? $month + 1 : 1).'&year='.($month != 12 ? $year : $year + 1).'" class="control">Next Month >></a>';



/* bringing the controls together */
$controls ='<center><form method="get">      '.$previous_month_link.'  '.$select_month_control.$select_year_control.' <input type="submit" name="submit" value="Go" />  '.$next_month_link.' </form></center>';

echo $controls;

previous/next function works great, but the pick a month is missing a part "?action=calendar;" and it returns just an empty page. Can someone help me with this one?
SimplePortal 2.3.8 © 2008-2024, SimplePortal