Thanks for the compliment, here's how it's done:
As stated, it's almost all done with includes and .php.
The directory structure is
Root /
Calender /calendar
I use 3 monthly archive templates to generate the following sets of files:
/YYYY_MM.inc -the include file for the homepage
/calendar/YYYY_MM.inc - the include file for the calendar homepage
/calendar/YYYY_MM.php - the monthly archive.
For the homepage I put in the following code:
CODE
<?PHP $calinc = date("Y_m", strtotime("-0 hours")); ?>
<?PHP include "$calinc.inc"; ?><br />
which includes the following template:
CODE
<?
$now = date("ymd", strtotime("-0 hours"));
?>
<table border="0" cellspacing="2" cellpadding="0" summary="Monthly calendar with links to each day's posts">
<tr>
<td><MTArchivePrevious><a href="<$MTArchiveLink$>"><<</a></MTArchivePrevious></td>
<td colspan="5" align="center" class="title"><$MTArchiveDate format="%B %Y"$></td>
<td align="right"><MTArchiveNext><a href="<$MTArchiveLink$>">>></a></MTArchiveNext></td>
</tr>
<tr>
<th abbr="Sunday" align="center"><span class="calendar">Sun</span></th>
<th abbr="Monday" align="center"><span class="calendar">Mon</span></th>
<th abbr="Tuesday" align="center"><span class="calendar">Tue</span></th>
<th abbr="Wednesday" align="center"><span class="calendar">Wed</span></th>
<th abbr="Thursday" align="center"><span class="calendar">Thu</span></th>
<th abbr="Friday" align="center"><span class="calendar">Fri</span></th>
<th abbr="Saturday" align="center"><span class="calendar">Sat</span></th>
</tr>
<MTCalendar month="this">
<MTCalendarWeekHeader><tr><? $counter = 0; ?></MTCalendarWeekHeader>
<MTCalendarIfEntries><MTEntries lastn="1"><td width="26" align="center"
<? if ("<$MTCalendarDate format="%y%m%d"$>"==$now) { ?>
class="calendartoday"
<? } else { ?>
class="calendaron"
<? } ?>
><a href="<$MTEntryPermalink archive_type="Monthly"$>"><$MTCalendarDay$></a></MTEntries></td>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><td width="26" align="center"
<? if ("<$MTCalendarDate format="%y%m%d"$>"==$now) { ?>
class="calendartoday"
<? } else { ?>
class="calendaroff"
<? } ?>
><$MTCalendarDay$><strong></strong></MTCalendarIfNoEntries>
<MTCalendarIfBlank><td width="26" align="center" class="calendaroff"> </td></MTCalendarIfBlank></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
<tr><td> </td></tr>
</table>
<?php
$db = mysql_connect("DBHOST", "USER", "PASS");
mysql_select_db("DATABASENAME",$db);
$result=mysql_query("SELECT * FROM mt_entry WHERE entry_blog_id = 4 AND entry_created_on >= CURDATE() ORDER by entry_created_on LIMIT 0,1;");
?>
<span class="calendar">Next Event</span><br />
<?
while ($data = mysql_fetch_array($result))
{
$myyear = date("Y", strtotime($data["entry_created_on"]));
$mymonth = date("m", strtotime($data["entry_created_on"]));
?>
<a href="/calendar/<?=$myyear?>_<?=$mymonth?>.php"><?=$data["entry_title"]?></a><br />
<?
}
?>
<br />
<?php
$db = mysql_connect("DBHOST", "USER", "PASS");
mysql_select_db("DATABASENAME",$db);
$result=mysql_query("SELECT * FROM mt_entry WHERE entry_blog_id = 4 AND entry_created_on >= CURDATE() ORDER by entry_created_on LIMIT 1,5;");
?>
<span class="calendar">Upcoming Events</span><br />
<?
while ($data = mysql_fetch_array($result))
{
$myyear = date("Y", strtotime($data["entry_created_on"]));
$mymonth = date("m", strtotime($data["entry_created_on"]));
?>
<a href="/calendar/<?=$myyear?>_<?=$mymonth?>.php"><?=$data["entry_title"]?></a><br />
<?
}
?>
I then use the same include code on the Calendar Index page which links to the following template:
CODE
<?
$now = date("ymd", strtotime("-0 hours"));
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="8" rowspan="2"><img src="/images/p.gif" width="8" height="100" alt="" border="0"></td>
<td width="200"><img src="/images/p.gif" width="200" height="8" alt="" border="0"></td>
<td width="16" rowspan="2"><img src="/images/p.gif" width="16" height="100" alt="" border="0"></td>
<td width="100%"></td>
<td width="8" rowspan="2"><img src="/images/p.gif" width="8" height="100" alt="" border="0"></td>
</tr>
<tr>
<td valign="top">
<form method="get" action="http://www.onpaintball.ca/admin/mt-search.cgi">
<input type="hidden" name="Template" value="onpaintball" />
<label for="search" accesskey="4"><strong>Search this site:</strong></label><br />
<input id="search" name="search" size="22" /> <input type="submit" value=" >> " /><br />
<img src="/images/tan_dk.gif" width="200" height="1" vspace="8" alt="" border="0"><br />
<span class="header">Events Calendar</span><br />
<br />
<table border="0" cellspacing="2" cellpadding="0" summary="Monthly calendar with links to each day's posts">
<tr>
<td><MTArchivePrevious><a href="<$MTArchiveLink$>"><<</a></MTArchivePrevious></td>
<td colspan="5" align="center" class="title"><$MTArchiveDate format="%B %Y"$></td>
<td align="right"><MTArchiveNext><a href="<$MTArchiveLink$>">>></a></MTArchiveNext></td>
</tr>
<tr>
<th abbr="Sunday" align="center"><span class="calendar">Sun</span></th>
<th abbr="Monday" align="center"><span class="calendar">Mon</span></th>
<th abbr="Tuesday" align="center"><span class="calendar">Tue</span></th>
<th abbr="Wednesday" align="center"><span class="calendar">Wed</span></th>
<th abbr="Thursday" align="center"><span class="calendar">Thu</span></th>
<th abbr="Friday" align="center"><span class="calendar">Fri</span></th>
<th abbr="Saturday" align="center"><span class="calendar">Sat</span></th>
</tr>
<MTCalendar month="this">
<MTCalendarWeekHeader><tr><? $counter = 0; ?></MTCalendarWeekHeader>
<MTCalendarIfEntries><MTEntries lastn="1"><td width="26" align="center"
<? if ("<$MTCalendarDate format="%y%m%d"$>"==$now) { ?>
class="calendartoday"
<? } else { ?>
class="calendaron"
<? } ?>
><a href="<$MTEntryPermalink archive_type="Monthly"$>"><$MTCalendarDay$></a></MTEntries></td>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><td width="26" align="center"
<? if ("<$MTCalendarDate format="%y%m%d"$>"==$now) { ?>
class="calendartoday"
<? } else { ?>
class="calendaroff"
<? } ?>
><$MTCalendarDay$><strong></strong></MTCalendarIfNoEntries>
<MTCalendarIfBlank><td width="26" align="center" class="calendaroff"> </td></MTCalendarIfBlank></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
<tr><td> </td></tr>
<tr><td colspan="7">
<?
$archivelist = array (<MTArchiveList archive_type="Monthly">
array ( sort=>"<$MTArchiveDate format="%Y%m"$>",
title=>"<$MTArchiveTitle$>",link=>"<$MTArchiveLink$>"),</MTArchiveList>);
sort ($archivelist);
for ($i=0;$i<count($archivelist);$i++) {
$title = $archivelist[$i][title];
$link = $archivelist[$i][link];
echo "<a href=\"$link\">$title</a><br />";
}
?>
<br />
Have an Event? <a href="mailto:events@onpaintball.ca">Tell Us!</a>
</td></tr>
</table>
</form>
</td>
<td valign="top"><span class="header">Events This Month</span><br />
<br />
<MTEntries sort_by="created_on" sort_order="ascend">
<a name="<$MTEntryID pad="1"$>"></a>
<span class="title"><$MTEntryTitle$></span><br />
<strong><$MTEntryDate format="%x"$></strong><br />
<br />
<$MTEntryBody$>
<MTEntryIfExtended>
<$MTEntryMore$>
</MTEntryIfExtended>
<br />
</MTEntries>
</td>
</tr>
</table>
and the monlthy template is pretty much identical to the include.
It's just very simple brute-force SQL queries. Not pretty but functional.
Hope that helps..
john.,
Bostich.com -
[sub]PIXEL.ca -
Paintball Ontario