Not a developer? Go to MovableType.com

Documentation

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__">)
    </li>
    <mt:If name="__last__"></ul></mt:If>
</mt:Entries>

Version History

Movable Type 4.0 and 4.1 supported these meta variables in the static publishing model only; not in the dynamic publishing model.

Back