<mt:IfCategory>
A conditional tag for determining if the entry in context is assigned categories. Determine if in a specific category and/or if the category is a primary or secondary category.
<mt:IfCategory>
<!-- Entry is assigned a category -->
</mt:IfCategory>
Attributes ¶
label ¶
The name of a category. Tests the category in context (or categories of an entry in context) to see if it matches with the given category name.
name ¶
Alias of label.
type ¶
Either the keyword “primary” or “secondary”. Used to test whether the specified category (specified by the label attribute) is a primary or secondary category assignment for the entry in context.
Examples ¶
Determine if the entry in context is assigned a category:
<mt:IfCategory>
<!-- Entry is assigned a category -->
<mt:Else>
<!-- Entry is not assigned a category -->
</mt:IfCategory>
Determine if the entry in context has a secondary category assigned:
<mt:IfCategory type="secondary">
<!-- entry in context is assigned to one or more secondary categories -->
</mt:IfCategory>
Determine if the entry in context is assigned the category “News”:
<mt:IfCategory label="News">
<!-- entry in context is assigned to the "News" category -->
</mt:IfCategory>
Determine if the entry in context is the in the primary category “News”:
<mt:IfCategory label="News" type="primary">
<!-- entry in context is assigned the primary category "News" -->
</mt:IfCategory>

Kai
January 8, 2008 1:21 AM | Reply
Hi there!
Is it possible to give the attributes a value with "MTGetVar" ?
Like this?
Cheers kai
The Ursine Calamity
May 28, 2008 5:50 PM | Reply
You can use this tag to display all entries EXCEPT those in a certain category, which is something that was really clumsy before and required plugins and scripts to make happen. For example:
...will return a list of all entries EXCEPT those in the Special Events category.
Conversely, you could use a different set of parameters and have the Special Events Category display differently than everything else. As a simple example:
...will return a list of all entries and all the entries in the Special Event category will be in bold type.
Beau Smith
replied to comment from Kai
July 30, 2008 2:51 AM | Reply
@kai -- yes, this is possible. Here's an example:
Chad Everett
September 25, 2008 8:10 AM | Reply
The attributes show as optional, and the first example illustrates that you can use MTIfCategory all by itself, presumably to test if an entry has a category at all. But as of MT 4.21, if you use it as such, it throws an error in an Entry template, saying that you did not specify the "type" attribute, implying that this usage is not permitted.
Beau Smith
replied to comment from Chad Everett
January 27, 2009 1:49 AM | Reply
Until a fix is implemented use
<mt:If tag="EntryCategory"></mt:If>