MTCalendar Fix

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:

<$MTEntryDate format="%Y/%m"$>/calendar.php

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.

8 Comments

  1. And it works! Now what else can I break?

  2. I got punked… Your comment preview deceived me! But I will never give up!!

  3. Isn’t it spelled Punk’d? And why ya gotta go breakin muh stuff? 🙂

  4. LOL! Now I see what you were trying to do! What’s all this?:

    <span style=”position: absolute; bottom: 0; color: green; font-size: 24px;”>
    Nice Try! hehehe.

  5. And again I am foiled!

    Clearly I am no match for one with your powers.

  6. <span class=”notgoingtohappen”>You Lose.</span>

  7. <span class=”storyofmylife”>::sigh::</span>

  8. Very informed and interesting comments! Greetings.

    casinos en ligne de france

Leave a Comment

Latest Tweet
  • @mariafrey Same here. It’s funny because we started an physical calendar w/ the kids this morning and I didn’t think about it until noon. :)
Somewhat Recent
The Whole Nine Yards