Dynamic Movable Type Calendar
I was never able to find a satisfactory solution to having a calendar in the sidebar of my Movable Type blogs, so a while back I set about to build one that I liked (you can see it at work on this blog). Thanks to some great code from Kevin Devens, I didn't have to figure out how to render a calendar, so I just needed to solve the problem of figuring out what days had blogs. The PHP code to do this is here: calendar.php.txt (6 Kb).
After the break are examples of using this in the various MovableType template types.
In the category & archive templates:
<div class="module-calendar module" id=calendar_module>
<?php
<MTENTRIES lastn="1">
$month = "<$MTEntryDate format="%m"$>";
$year= <$MTEntryDate format="%Y"$>;
</MTENTRIES>
include ("http://www.yoursite.com/calendar.php?month=$month&year=$year&rootdir=yourblog" );
?>
</div>
In the date-based templates:
<div class="module-calendar module" id=calendar_module>
<?php
$month = "<$MTArchiveDate format="%m"$>";
$year= <$MTArchiveDate format="%Y"$>;
include ("http://www.yoursite.com/calendar.php?month=$month&year=$year&rootdir=yourblog" );
?>
</div>
In the individual entry template:
<div class="module-calendar module" id=calendar_module>
<?php
$month = "<$MTEntryDate format="%m"$>";
$year= <$MTEntryDate format="%Y"$>;
include ("http://www.yoursite.com/calendar.php?month=$month&year=$year&rootdir=yourblog" );
?>
</div>
In the main index template:
<div class="module-calendar module" id=calendar_module>
<?php
$month = "<$MTDate format="%m"$>";
$year= <$MTDate format="%Y"$>;
include ("http://www.yoursite.com/calendar.php?month=$month&year=$year&rootdir=yourblog" );
?>
</div>
Comments
