Don't Back Down

Posted by Chad Everett on September 8, 2003

MT-SomeDays 1.2.0 »

I didn't like the way that MT-SomeDays used different code to do the what was essentially the same task for different loops, but I couldn't figure out how to get the functions in a subroutine. Well, I finally figured it out. Once this was done, it became really easy to add some new functionality to the plugin. So that's just what I did.

Version 1.2.0 adds new conditional tags and also some new options for the select attribute.

You may recall that the select attribute was used to select an entire week of dates, somewhat like the MTCalendar function in Movable Type, but for a week. If you didn't use the select attribute, the plugin returns only a single date.

Now you have three new options for the select attribute:

<MTSomeDays select="month"> - selects the entire month
<MTSomeDays select="year"> - selects the entire year
<MTSomeDays select="X"> - selects the previous X days

The month and year will take the date and select the entire surrounding month or year, respectively. This is a calendar month and a calendar year. Using select="month" in your template will result in something relatively close to the built-in MTCalendar function.

The year will allow you to return a whole year's worth of blog entries. Used in conjunction with the year="last" or year="next" attributes, you can create a template with all of last year's or all of next year's posts. This probably isn't well suited to a yearly archive, but should work well for a last year/next year indicator on archive pages.

The select="X" attribute allows you to tell the plugin how many days you'd like to see. For instance, perhaps you only want the last 4 days. Or the last 90 days. It's up to you. Now you can specify your range, and all those dates will be returned. Using the conditional tags, you can pull in dates only with entries, only dates without entries, or pretty much anything else you might be able to imagine.

It's important to remember that the select attribute is used to select data after the date has been set using the date, offset, week or year attributes. So you are able to move back four weeks, return three days of data and only display something if it's Thursday and there are no entries on that day. Would you do this? Probably not. But you can.

Speaking of conditional tags, there are four new ones:

<MTSDIfEvenMonth></MTSDIfEvenMonth> - month 2, 4, 6, 8, 10, 12
<MTSDIfOddMonth></MTSDIfOddMonth> - month 1, 3, 5, 7, 9, 11
<MTSDIfWeekday></MTSDIfWeekday> - weekday (dow 1-5)
<MTSDIfWeekend></MTSDIfWeekend> - weekday (dow 0 or 6)

These should be pretty self explanatory. Let me know if the functions aren't clear.

Whew. I'm out of breath. Now it's up to you.

Announcement. Download.

Related Entries

Leave a comment