user-pic

Supressing Future Months in an ArchiveList

Vote 0 Votes

We’re running an events calendar by creating posts in a category and dating the posts with the date of the event. This is all working fine. The unintended side-effect is that an ArchiveList type=”Monthly” tag now outputs months in the future, which we don’t really want.

Is there a built-in way to suppress those? I’ve been trying to do it by comparing the current date with the archive date in the archive list, and only printing out list items that are older than the current date, but it’s not working at all.

I’ve tried several variations on the following code, although it really seems like this should work:

<mt:Date format="%Y%m" setvar="currentMonth" />
<mt:ArchiveList archive_type="Monthly">
    <mt:ArchiveDateEnd format="%Y%m" setvar="archiveMonth" />
    <mt:If var="archiveMonth" le="$currentMonth">
        <p><$mt:ArchiveTitle$></p>
    </mt:If>
</mt:ArchiveList>

If I include <mt:Var name="archiveMonth" /> and <mt:Var name="currentMonth" /> in the output paragraph, both show the values I would expect.

However, it seems like the mt:If tag is not getting checked at all; all months print out.

Any pointers on either how to achieve what I’m after, or what I might be doing wrong in that block up there?

Reported on Movable Type 4.2

1 Reply

| Add a Reply
  • David - Your code worked for me in MT4.2.

    You're doing it exactly as I would suggest.

    To test I placed the following code into an index template and then published an entry in the future. (sounds funny =)

    <ul>
    <mt:ArchiveList archive_type="Monthly">
        <li><a href="<$mt:ArchiveLink$>"><$mt:ArchiveTitle$> (<$mt:ArchiveCount$>)</a></li>
    </mt:ArchiveList>
    </ul>
    
    <hr />
    
    <mt:Date format="%Y%m" setvar="currentMonth" />
    <p>currentMonth: <$mt:var name="currentMonth"$></p>
    <ul>
    <mt:ArchiveList archive_type="Monthly">
        <mt:ArchiveDateEnd format="%Y%m" setvar="archiveMonth" />
        <mt:If var="archiveMonth" le="$currentMonth">
            <li><$mt:ArchiveTitle$> [<$mt:var name="archiveMonth"$>]</li>
        </mt:If>
    </mt:ArchiveList>
    </ul>
    

    Here's the ouput:

    What plugins do you have installed?

Add a Reply

Forum Groups

151 405

Last Topic: MT Interface Missing by Sherri on Nov 10, 2008

36 144

Last Topic: Installation can't finish by Drazend on Nov 10, 2008

34 93

Last Topic: Creating your own Plug-in by jondauz on Nov 5, 2008

10 33

Last Topic: new licensing confusion by Neil Epstein on Aug 14, 2008

code.sixapart.com

62 226

Last Topic: Callback after blog publishing. by Tomato Interactive on Oct 27, 2008

34 98

Last Topic: Ajax Rating Plugin by kiran on Oct 17, 2008