tips and tricks for movable type
two calendars reverse sort
February 01, 2003
Here's some code I've been meaning to post for a while (though I can't claim complete credit for it, as it was just me patching together other stuff in this support forum thread). It allows you to display two calendars together in reverse order (oldest first).
You may already know that you can surround your MT Calendar tags with an MTArchiveList tag to display multiple calendars (sample code courtesy of Kristine):
<MTArchiveList lastn="2" archive_type="Monthly">
<td width="250">
All the other center stuff from the other post besides the MTArchiveList Container
</td>
</MTArchiveList>
</tr></table>
The 2 tells MT how many calendars you want to display. But, because MTArchiveList doesn't offer any sort options, the calendars will appear from newest to oldest. If you want to reverse that, here's the code.
Two Calendars in Reverse Order, Side by Side:
<?php
<MTArchiveList lastn="2" archive_type="Monthly">
$monthlyarchivereverse[] =
"<td width=\"250\">
<table border=\"0\" cellspacing=\"4\" cellpadding=\"0\" summary=\"Monthly calendar\">
<caption><$MTArchiveDate format="%B %Y"$></caption>
<tr>
<th abbr=\"Sunday\" align=\"center\">Sun</th>
<th abbr=\"Monday\" align=\"center\">Mon</th>
<th abbr=\"Tuesday\" align=\"center\">Tue</th>
<th abbr=\"Wednesday\" align=\"center\">Wed</th>
<th abbr=\"Thursday\" align=\"center\">Thu</th>
<th abbr=\"Friday\" align=\"center\">Fri</th>
<th abbr=\"Saturday\" align=\"center\">Sat</th>
</tr> <MTCalendar month="this">
<MTCalendarWeekHeader><tr></MTCalendarWeekHeader>
<td <MTCalendarIfToday>bgcolor=\"#EEEEEE\"</MTCalendarIfToday> align=\"center\">
<MTCalendarIfEntries><MTEntries lastn="1"><a href=\"<$MTEntryLink$>\"><$MTCalendarDay$></a></MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfBlank> </MTCalendarIfBlank></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
</table>
</td>";
</MTArchiveList>
$monthlyarchive = array_reverse($monthlyarchivereverse);
foreach($monthlyarchive as $temp) {
echo $temp;
}
?>
</tr></table>
View a demo here.
Two Calendars in Reverse Order, Top to Bottom:
<?php
<MTArchiveList lastn="2" archive_type="Monthly">
$monthlyarchivereverse[] =
"<table border=\"0\" cellspacing=\"4\" cellpadding=\"0\" summary=\"Monthly calendar\">
<caption><$MTArchiveDate format="%B %Y"$></caption>
<tr>
<th abbr=\"Sunday\" align=\"center\">Sun</th>
<th abbr=\"Monday\" align=\"center\">Mon</th>
<th abbr=\"Tuesday\" align=\"center\">Tue</th>
<th abbr=\"Wednesday\" align=\"center\">Wed</th>
<th abbr=\"Thursday\" align=\"center\">Thu</th>
<th abbr=\"Friday\" align=\"center\">Fri</th>
<th abbr=\"Saturday\" align=\"center\">Sat</th>
</tr>
<MTCalendar month="this">
<MTCalendarWeekHeader><tr></MTCalendarWeekHeader>
<td <MTCalendarIfToday>bgcolor=\"#EEEEEE\"</MTCalendarIfToday> align=\"center\">
<MTCalendarIfEntries><MTEntries lastn="1"><a href=\"<$MTEntryLink$>\"><$MTCalendarDay$></a></MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfBlank> </MTCalendarIfBlank></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
</table>
<br /><br />";
</MTArchiveList>
$monthlyarchive = array_reverse($monthlyarchivereverse);
foreach($monthlyarchive as $temp) {
echo $temp;
}
?>
</div>
View a demo here.
TrackBack: 1
(URL: http://www.thegirliematters.com/sf/mt-track.cgi/138)
» Various tricks with archive calendars
Excerpt: These tricks apply to the tiny calendars that appear on your home page, not the full-screen monthly archives from my
Weblog: Sillybean
Tracked: 02.14.03 01:57 PM
Comments
ohmigod ohmigod! girls, this place is looking good!!
Maybe someday I will use this !
Okay simple question for most of you I am sure, but one that I can't yet get my head round. I've just started an online diary at www.markusrandall.com - but I want to set it up so that you scroll through entries for a given day in chronical order i.e. not most recent first, but earliest first. So, 9am comes up before 10pm. Any ideas how to simply switch this over?
Okay - I worked it out - scrap that request!
So I'm kinda happy with one calendar. When I'm annoyed is days such as this when June is now totally empty with no entries. What I really want is to see the last five or six weeks in entries from with today as the ending date. Doesn't that seem more useful? Just a thought...
brilliant. this is exactly what i was lookig for. you've saved me a night of frustration and using the lord's name in vain.
is there a way to do it without php? thanks!