Help - Search - Members - Calendar
Full Version: showing entries by offset or category
Movable Type Community Forum > Additional Resources > Tips and Tricks
-lc-
I've been out of the loop from doing MT customizing for several months so please forgive me, I've gotten all rusty sad.gif I can almost think this out but just can't envision the final code.

Given the currest plugins available, what is the easist way to do a list of entries based on an offset or if they were labeled into a certain category?

For example there are 100 posts. I have labeled a few into a category called "outdated". Now I want a list of old entries starting at an offset of 40 (normally giving a list of 60 entries) but also to show any in the first 40 that have been labeled as "outdated".

The offset is easy normally but now I obviously have to loop through all 100 and first check category and then check for count.

Ouch my brain hurts, please help if you have the time, many thanks.
staggernation
You could use the Supplemental Category Tags plugin. Something like this (untested):
CODE
<!--display "outdated" entries from the last 40-->
<MTEntries lastn="40">
<MTIfCategory name="outdated">
<!--CODE TO DISPLAY THE ENTRY HERE-->
</MTIfCategory>
</MTEntries>

<!--now display all the remaining entries-->
<MTEntries offset="40" lastn="999">
<!--CODE TO DISPLAY THE ENTRY HERE-->
</MTEntries>

This means duplicating all the "display entry" code (or you could use a template module), but that's the most straightforward way that occurs to me at first glance.
-lc-
Ah, thanks for thinking that out for me Kevin. The only improvement I could hope for is to reduce the code to to use just one section for the display (instead of repeating it twice) but your example will definitely work as is.

And if it hasn't been said (enough) many thanks for all your great plugins, you are a huge asset to the MT community!
staggernation
Well, thanks for the kind words.

To do the required logic without duplicating the entry listing code, I think you'd need either

A) MTPerlScript and some Perl code, or

B) a plugin tag that would let you increment a variable counter (would be easy to write, but I'm not aware of an existing one), plus the MTSetVarBlock and Compare plugins in addition to Supplemental Category Tags.

Probably easier to just stick the entry code in twice...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.