Template Loop Meta Variables
Movable Type exposes a number of different template tags called container tags that loop over a set of objects. This allows designers to display for example the last 10 entries on a blog, or to display each of the comments associated with an entry.
As Movable Type iterates or loops over a list of objects in this fashion it maintains a number of meta variables for you, allowing you to test if the current item is an odd or even item in the list for example.
Loop Meta Variables ¶
Note: Each of these variables is preceded and followed by two (2) underscores.
__even__- returns true if the current item in the list is even__odd__- returns true if the current item in the list is odd__first__- returns true if the current item in the list if the first item in the list__last__- returns true if the current item in the list if the last item in the list__counter__- returns the index of the current item in the list
Examples ¶
List the most recent 10 entries in a unordered list. Adding "odd' and "even" classes. Note the order in the list in parenthesis:
<mt:Entries lastn="10">
<mt:if name="__first__"><ul></mt:if>
<li class="entry <mt:if name="__even__">even<mt:else>odd</mt:if>">
<mt:EntryTitle> (<mt:var name="__counter__">0
</li>
<mt:if name="__last__"></ul></mt:if>
</mt:Entries>
Related ¶
<mt:Entries><mt:Pages><mt:Authors><mt:Blogs><mt:Categories>- etc... and all other loop block tags in Movable Type

Su
December 2, 2007 1:26 PM | Reply
This should really be linked from each of the relevant loops, such as Entries. A lot of people don't know about them, and right now, it's being relied upon for them to come into the designer's guide, which presumes a certain interpretation, eg. in most of my client relationships, I would probably identify as the admin, not designer.
Beau Smith
replied to comment from Su
March 5, 2008 4:42 PM | Reply
Thanks Su. I've added a link under Related Entries on all the major loop/block tags in the documentation, and added the tag "block" to this page.
Su
March 12, 2008 9:38 PM | Reply
FYI: These meta-variables are not available under dynamic publishing.