16 Aprili 2003

Placeholder attributes

You have gathered by now, I hope, that some Movable Type placeholders play chameleon, changing their stripes depending on what’s surrounding them.

For some placeholders, there’s another way to tweak what they do: adding one or more attributes to them.

If you do HTML at all, you understand the idea of an attribute already. In the quite feasible HTML tag <h2 class="subtitle">, there is an attribute class with the value subtitle. Attributes typically describe and/or limit what they’re attached to.

Movable Type placeholder attributes work the same way HTML attributes do, both in syntax and intent. Hooray for transferable knowledge.

Some attributes can (theoretically, at least; in the real world some of them won’t make sense everywhere) be used on any Movable Type placeholder. The Movable Type documentation calls these “Global Tag Attributes” and does such a fine job of describing them that I don’t feel the need to recap.

Most attributes, though, are specific to specific placeholders. The <MTCalendar> placeholder, for example, has a month attribute that lets you specify which month you want to display. Acceptable values are “this” for this month, “last” for last month, or a six-digit number containing the four-digit year and two-digit month, like 200304 for April 2003.

So if I have such an undying love for this month that I want its calendar somewhere on all my blog pages, I would start the calendar in my template with <MTCalendar month="200304">. Simple as that. (Then I’d have to put in a bunch of other calendar placeholders, which are not simple at all… but I digress.)

This may seem a silly thing to say, but here I go anyway: Don’t use Movable Type attributes on HTML tags, and don’t use HTML attributes on Movable Type placeholders. Won’t work. (This is another reason I wish the syntax for Movable Type placeholders weren’t so HTML-ish. Yes, I know I just said “hooray for transferable knowledge,” but there’s also a confusion cost.)

That’s it. Easy lesson. Next up: the weird and wonderful <MTEntries> placeholder, without which no blog template is complete.