Using Entry Separators

It’s very easy to insert separators into Movable Type. Simply place them at the bottom of your MTEntries loop, and after every entry you will have a separator.

Something like this will work very well:

  <MTEntries>
  <MTEntryBody>
  <hr />
  </MTEntries>

And when you rebuild this template, you will get your entry body, followed by a horizontal rule, followed by an entry body, followed by a horiztontal rule, and so on. But what happens when you get to the end of the list and you don’t want another separator because there’s nothing after the last entry that needs separating?

At that point, you have two choices. Either leave it, and don’t worry about a dangling horizontal rule as you try and get to sleep at night, or come up with a way to not print it. If you choose not to worry about it, stop reading. You obviously don’t spend enough time obsessing about your site to be the target audience of this post.

The MTEntriesFooter tag seems tailor-made for such a purpose, putting something at the bottom of your entry list, but it’s just the opposite of what you need. It will serve to put the horizontal rule there, but not to keep from putting it there.

MTElse to the rescue. The MTElse tag is designed to offer the other condition – in other words, to show you when the bit you are checking is not true. Just what we need.

You use MTElse just like any other conditional tag – that is, you wrap it around the content you want to print if the condition is true. However, you can’t use it by yourself – it must be used within another condition, or it won’t know what to check! Something like this should do the trick for us:

  <MTEntries>
  <MTEntryBody>
  <MTEntriesFooter>
  <MTElse>
   <hr />
  </MTElse>
  </MTEntriesFooter>
  </MTEntries>

Notice that the actual MTEntriesFooter tag doesn’t contain anything – so if you reach the end of your entry list, nothing will print. On the other hand, if it’s not the end of the list, MTElse will trigger and print the information contained within it – in this case, our horizontal rule.


Posted

in

Comments

3 responses to “Using Entry Separators”

  1. Kevin Shay Avatar

    Hey, great trick!

    And for separators in non-MTEntries situations, where there’s not an equivalent footer conditional tag, there’s always my Glue plugin

  2. Joerg Petermann Avatar

    Simple and easy. Good! 🙂