Don't Back Down

Posted by Chad Everett on September 1, 2003

MT-SomeDays 1.0.0 »

I had looked around for a way to create a calendar in my blog that worked like the <MTCalendar> container, but for a week instead of a month. There are all sorts of plugins out there that come close.

Brad Choate has a plugin called onthisday, that allows you to show entries from the same day and different years. Kevin Shay offers DateTags, that probably does everything I want, but looked too complex to me.

Even Movable Type has the days="7" function that comes close - but it includes only entries, and not the days without. So I wrote my own.

Introducing SomeDays. I'll put together a more detailed page later this week, but I wanted to get this out there in case anyone else wanted the same thing (and to get some people to test it!). In a nutshell: SomeDays offers a container that's roughly akin to the <MTCalendar> container. Using it allows for the selection of entries from particular days.

Specifying additional qualifiers on the <MTSomeDays> container tag allows you to adjust the date. By default, the date is the current date - which is generally the system date, but may also be a different date in the context of an individual entry archive.

Using the date="YYYYMMDD" tag allows you to specify a particular date. Using the week="last" or week="next" tag allows you to move forward or backwards relative to the current date. The year="next" and year="last" tags work similarly. There's also an offset modifier that lets you adjust the week forward or backwards, and works in conjunction with the other values - so you can move 4 weeks before the current date, for instance, by specifying offset="4".

By default, the <MTSomeDays> tag will return only a single date. Add select="week" to return the entire calendar week (Sunday through Saturday). And because the SomeDays plugin is date-driven, and not entry-driven, you get information to work with even on days with no entries present.

The <$MTSDEndDate$>, <$MTSDStartDate$> and <$MTSDWorkDate$> return MT-formattable date strings for the start of your range, the end of your range and the current processing date (all three will be the same if you're using only a single day). <$MTSDDayOfWeek$> returns the day of the week (0-6), useful for formatting by style sheet.

Conditional container tags <MTSDIfEntries&>, <MTSDIfNoEntries>, <MTSDIfToday> and <MTSDIfNotToday> allow you to show data only if particular conditions are met. And there are even conditional tags for days of the week - <MTSDIfSunday> through <MTSDIfSaturday>.

Using the full range of features allows you to return something as obscure as Tuesday from four weeks ago:

<MTSomeDays offset="4" select="week">
<MTSDIfTuesday>
<MTEntries>
<MTDateHeader>
<a href="<$MTEntryLink archive_type="Daily"$>">
<strong><$MTEntryDate format="%Y"$></strong>:
</a><br />
</MTDateHeader>
<div><$MTEntryExcerpt$></div>
</MTEntries>
</MTSDIfTuesday>
</MTSomeDays>

Why? Who knows. I don't know that I'd do it that way. But you could. :)

Sound interesting? More detailed info is in Announcement. Download.

Related Entries

Leave a comment