I'm trying to output a series of entries as a list but I need to be able to mark each third one with a special CSS class. I noted that there's something that does exactly what I need for outputting assets but not entries. i've been stumbling through trying to get something working for entries for a couple hours now with no luck and am hoping someone can help.
The gist of what I'm looking to produce is this:
<ul> <li>Entry one</li> <li>Entry two</li> <li class="last">Entry three</li> <li>Entry four</li> <li>Entry five</li> <li class="last">Entry six</li> <li>Entry seven</li> </ul>
This is simple to do with assets using the mt:FirstAssetInRow or mt:LastAssetInRow tags with the "assets_per_row" argument on the mt:Assets tag but nothing like that exists for entries :(
Reported on Movable Type 4.3
The general trend is moving away from things like EntriesHeader, because such constructs are specific to the point of being limiting if you want to do anything that's just slightly different. Those asset tags work out for you in this particular situation(when you're using assets), but that's not really what they're for. Anyway, back to the question.
Most of the major loops now have a set of meta-variables available to them. You're currently interested in __counter__ Odd and even are handy shortcuts for on/off situations, but since you're working with threes, you have to do a bit of the work yourself. For that you want the If tag. Then:
Although, you bringing up the asset tags is making me wonder exactly what you're doing. Are you just marking off every third item, or is the end goal a grid? Because there's a plugin that addresses that directly, and has several more options that you might find useful.
Thanks so much Su - works like a charm.
I had a feeling there had to be a simple way to do what I needed. I think I was just over complicating things and not thinking though the options available or misunderstanding how some of the meta variables work.
The end goal visually was something resembling a grid layout (but not using a table). I had looked at the MTGrid plugin but that seemed like overkill for what I needed.
Just as a quick note on this in case you do end up needing any of that extra stuff, the Grid plugin makes no assumptions at all about the markup. All it does is provide the structures for dealing with your content bits in a grid-like format.
MTGrid is fantastic even for CSS layouts, but it doesn't provide the ability to do complex array counting operations as Su has demonstrated above. For example, in some grid layouts you may want to apply CSS formatting to additional cells other than just the left/first and right/last cells in a row. In my experiments with MTGrid, this isn't always possible depending on what one is trying to do.
That said, some combination of MT's array counting functions and MTGrid could work beautifully.