Don't Back Down

Posted by Chad Everett on September 2, 2003

MT-SomeDays 1.1.0 »

When I actually went to implement MT-SomeDays, I found some problems.

First was a non-numeric message when using the <$MTSDWorkDate$> tag when used in conjunction with the format option. It would actually work correctly, so long as your format pattern did not include hours minutes or seconds, but it would return messages.

I also decided that I needed some more conditionals to select data when it is not a particular day (for instance, <MTSDIfNotSaturday>). In particular, I used this in the loop to only print the separator when it's not the last day of the week. Something like this:

      <MTSomeDays select="week">
        <$MTSDWorkDate format="%A"$>
        <MTSDIfNotSaturday>&middot;</MTSDIfNotSaturday>
      </MTSomeDays>

This prints the &middot; character (·) after each processed date, unless the day is Saturday - in that case, we don't want it because the list is done. The end result is a week's worth of entries:

Sunday · Monday · Tuesday · Wednesday · Thursday · Friday · Saturday

How about highlighting today so it really stands out?

Sunday · Monday · Tuesday · Wednesday · Thursday · Friday · Saturday

Making use of the <MTSDIfToday> and <MTSDIfNotToday> tags, we can easily highlight today's date within that list. Here's the code to make it happen:

<MTSomeDays select="week">
<MTSDIfToday>
<strong><$MTSDWorkDate format="%A"$></strong>
</MTSDIfToday>
<MTSDIfNotToday>
<$MTSDWorkDate format="%A"$>
</MTSDIfNotToday>
<MTSDIfNotSaturday>&middot;</MTSDIfNotSaturday>
</MTSomeDays>

Announcement. Download.

Related Entries

Leave a comment