Help - Search - Members - Calendar
Full Version: Excluding categories from date-based archives
Movable Type Community Forum > Additional Resources > Tips and Tricks
tingarden
I would like my monthly archives to exclude certain categories. When I use the "category" attribute on the db archive template, it ignores the dates. Any suggestions? TIA!
trialanderror
I needed something similar, but for daily archives. To make this work, you will need the MTCompare and MTTagInvoke plugins. This will enable you to exclude categories and still use the code with MTArchiveList.

CODE
<MTSetVar name="linkisdupe" value="123aaa123">
<MTArchiveList archive_type="Daily">

<MTEntries>
<MTIfNotEqual a="[MTEntryCategory]" b="excludethiscategory">

<MTIfNotEqual a="[MTGetVar name='linkisdupe']" b="[MTArchiveDate format='%x']">
<a href="<MTEntryLink archive_type="Daily">"><MTArchiveDate></a><br>
<MTEntryLink archive_type="Daily"><br>
<MTTagInvoke tag_name="MTSetVar" name="linkisdupe">
<MTTagAttribute name="value"><MTArchiveDate format="%x"></MTTagAttribute>
</MTTagInvoke>
</MTIfNotEqual>

[<$MTEntryTitle$>]<br><br>
</MTIfNotEqual>
</MTEntries>
</MTArchiveList>


Which will give you the same output as...

CODE
<MTArchiveList>
 <a href="<$MTArchiveLink$>"><$MTArchiveDate$></a><br>
 <MTEntries>
   [<$MTEntryTitle$>]
 </MTEntries>
</MTArchiveList>


The 123aaa123 value in the setvar command is an arbituary selection. It's just to assign some initial value to "linkisdupe" that is unlikely to match a date.

You exclude your category with
CODE
<MTIfNotEqual a="[MTEntryCategory]" b="excludethiscategory">


I think you can exclude more than one category, but I have not tested it. (So I don't know for sure) Your code would look something like this...

CODE
MTIfNotEqual a="[MTEntryCategory]" b="excludethiscategory" b1="anothercategory" b2="yetanothercategory">


hope this helps

t&e
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.