OK, I know there are several of you out there
(myself included) that want or wanted to include
previous and next month links on the calendar to make navigation
just a little bit easier. I also know what a pain it can be
to sort through all those invaluable hacks trying to find the
few lines of code to copy and paste into your own script. To
make things a little easier for those of you who
want to include this modification in the calendar script, I've
taken some code from the Marlboro Calendar Hacks, cleaned
it up a bit, and summarized the steps below.
Step 1:
Copy and paste the following lines somewhere
close to the bottom in the section called "Subroutines".
However, be careful not to put it into one of the
existing subroutines:
sub prev_next
{
if ($currentmonth == 12)
{
$nextmonth = 1;
$nextyear = $currentyear + 1;
}
else
{
$nextyear = $currentyear;
$nextmonth = $currentmonth + 1;
}
$next_list = "year=$nextyear";
$next_list .= "&month=$nextmonth";
$next_list .=
"&session_file=$session_file";
$next_list .=
"&calendar=$form_data{'calendar'}";
$next_url = $this_script_url;
$next_url .= "?";
$next_url .= $next_list;
if ($currentmonth == 1)
{
$lastmonth=12;
$lastyear = $currentyear - 1;
}
else
{
$lastyear = $currentyear;
$lastmonth = $currentmonth - 1;
}
$last_list = "year=$lastyear";
$last_list .= "&month=$lastmonth";
$last_list .=
"&session_file=$session_file";
$last_list .=
"&calendar=$form_data{'calendar'}";
$last_url = $this_script_url;
$last_url .= "?";
$last_url .= $last_list;
}
Step 2:
Scroll back up close to the top of the script,
and in the section called "Print out Calendar", just
before the line that says "# Now print out the HTML calendar",
insert the following line:
&prev_next;
Step 3:
Where the script is actually printing out the
HTML for the calendar view (just a few lines down from the
line we just inserted), use the following link tags to call
the previous and next months:
Previous Month
Next Month
Of course, you will want to place the link tags
in an appropriate place on the page. Similarly, you
can modify the HTML in the link tags to use images
(buttons) rather than text.
I really hope this helps!
Daniel McFall
Independent Computer Services
dmcfall@labyrinthwebservices.co