PDA

View Full Version : Display multiple months


keithh0427
05-29-2005, 10:30 PM
Is there a way to display last month, this month, and next month? Similar to working on the events page of setup.

ve9gra
05-30-2005, 05:55 AM
If you reset the $mo variable before calling the listing module, it is possible. Add this $mo = $mo - 1;
if ($mo == 0) {
$mo = 12;
$yr = $yr - 1;
}
$listMonths = 3; That should do the trick.

Arthur
05-31-2005, 08:29 PM
Thanks, ve9gra.

Just one question: in what file/module is this code added, and where? I'd be grateful for fuller info as I'm a real n00b. Ta lot.

keithh0427
05-31-2005, 08:31 PM
This code would be placed in the HTML page that is calling the calendar.

Arthur
05-31-2005, 08:37 PM
Thanks.
I must be really thick. Just tried adding this text but it still shows the single month, with the text across the top in one line, asin this test:

www.williamson.co.za/test1.php (http://www.williamson.co.za/test1.php)

keithh0427
05-31-2005, 08:56 PM
You need to wrap it all in php

Try this:

<?php
$mo = $mo - 1;
if ($mo == 0) {
$mo = 12;
$yr = $yr - 1;
}
$listMonths = 3;
?>

If you need this month and next month, it would be:

<?php
$mo = $mo + 1;
if ($mo == 13) {
$mo = 1;
$yr = $yr + 1;
}
$listMonths = 3;
?>

keithh0427
05-31-2005, 09:05 PM
Just to be safe, here's some live code that I'm using.

<?php
echo "<table><tr>";
$noNav = 1;
echo "<td align=\"center\">";
require("calendar/calendar.php");
$mo++;
if (++$mo > 12) {
$mo = 1;
$yr++;
}
echo "</td>";
echo "<td align=\"center\">";
require("calendar/calendar.php");
$mo++;
if (++$mo > 12) {
$mo = 1;
$yr++;
}
echo "</td>";
echo "<td align=\"center\">";
require("calendar/calendar.php");
echo "</td>";
echo "</tr></table>";
?>

This will display 3 months in a horizontal fashion. You can increase the distance between the months by varying the table parameters such as padding, etc.

Also, note the use of $noNav = 1;. You will need to use that to turn off the navigation beneath each calendar. Pretty messy if you don't.

keithh0427
05-31-2005, 09:27 PM
Arthur,

Here's a complete .php file that I just tested.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<?php $CSS=1; require("calendar/calendar.php"); ?>
</head>

<body>
<?php $OL=1; require("calendar/calendar.php"); ?>
<?php
echo "<table cellspacing='0' cellpadding='35'><tr>";
$noNav = 1;
echo "<td align=\"center\">";
require("calendar/calendar.php");
$mo++;
if ($mo > 12) {
$mo = 1;
$yr++;
}
echo "</td>";
echo "<td align=\"center\">";
require("calendar/calendar.php");
$mo++;
if ($mo > 12) {
$mo = 1;
$yr++;
}
echo "</td>";
echo "<td align=\"center\">";
require("calendar/calendar.php");
echo "</td>";
echo "</tr></table>";
?>

<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

keithh0427
05-31-2005, 09:54 PM
Arthur,

Take a look at http://alifetimeoflove.org/calendar.php

Hopefully, that's what your looking for. The months change by three, cut can easily be setup to change by one.

ve9gra
06-01-2005, 06:05 AM
So sorry Arthur... I had misunderstood your inquery. I thought you wanted to have 3 months displayed in the listing module and only the current month for the calendar.

Here's the full code to what you want to do. Please make sure you adjust the paths accordingly to your installation.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Calendar</title>
<?php $CSS=1; require("calendar/calendar.php"); ?>
</head>

<body>
<?php $OL=1; require("calendar/calendar.php"); ?>
<?php
import_request_variables("gp");
if (!isset($yr)) $yr=date("Y");
if (!isset($mo)) $mo=date("n");
$lastMonth = $mo - 1;
$lastYear = $yr;
if ($lastMonth == 0) { $lastMonth = 12; $lastYear--; }
$curMonth = $mo;
$curYear = $yr;
$nextMonth = $mo + 1;
$nextYear = $yr;
if ($nextMonth == 13) { $nextMonth = 1; $nextYear++; }

echo "<table cellspacing='0' cellpadding='35'><tr>";
$noNav = 1;
echo "<td align=\"center\">";
$mo = $lastMonth;
$yr = $lastYear;
require("calendar/calendar.php");
echo "</td>";
echo "<td align=\"center\">";
$mo = $curMonth;
$yr = $curYear;
require("calendar/calendar.php");
echo "</td>";
echo "<td align=\"center\">";
$mo = $nextMonth;
$yr = $nextYear;
require("calendar/calendar.php");
echo "</td>";
echo "</tr></table>";
?>
</body>
</html>