A friend of mine noted this weekend that the calendar that shows up on my archive pages wasn’t working properly:
When looking at one of your archived entries, say:
20 inch Intimidation
the calendar shows all the red days with posts before the currently shown entry, but only the first entry following it instead of an accurate look at the whole month.
The error was due to a very simple principle that I had overlooked when creating my individual archive pages, MTCalendar isn’t dynamic. I don’t know how I missed this, but when you publish an entry in Movable Type, an archive page for that entry is created. If you include the MTCalendar in the template for that page, it produces the calendar showing all of the entries up to that date. If you publish another entry later, it will not show up on that calendar because it wouldn’t be updated unless you republished the entire site.
I thought this would be a well documented problem for which I could Google up dozens of fixes, but I was wrong. I couldn’t find a single solution. After about an hour of trial and error brainstorming, I had an answer.
In order to make the calendar dynamic, I had to modularize it. My initial idea was to create a second monthly date-based archive template and then include it on my individual entry archives. Because I could only have one preferred monthly archive, I had to settle for making it a weekly archive with the Archive File Template set to:
This way, every archive/YYYY/MM folder has a file called calendar.php in it. Whenever I publish an entry during a given week, the monthly calendar file will be rebuilt by movable type. Since each individual entry file includes that calendar.php file, there will never be an out of date calendar on the site.