Chapter Category
MTIfCategory
A conditional block which tests attributes of the category currently in context and outputs its contents on a match.
This tag can be used anywhere where there is a category context:
- Within an MTEntries loop
- In a category archive template
- Within an MTCategories loop
- Etc
Required attributes
name- Name of category for conditional testlabel- Alias ofnameattribute above
Optional attribute
type- Tests for the assignment type for the category, accepting values ofprimaryandsecondary.
NOTE: There is currently a known issue related to this in that the value of 'secondary' is not accepted by the type attribute.
Example code
Conditional output based on category:
<MTIfCategory label="important">
This is important
<MTElse>
Misc is not so important
</MTElse>
</MTIfCategory>
This can be used in conjuction with CSS rules to display things differentially. This adds a class attribute of featured to the entry title h2 tag if the category of the entry is "Featured":
<h2 <MTIfCategory name="Featured">class="featured"</MTIfCategory>>
<MTEntryTitle>
</h2>
Below is a full example testing for not only category assignment, but also the type of assignment.
<MTIfCategory label="misc" type="primary">
Misc is the primary category
<MTElse>
<MTIfCategory label="misc" type="secondary">
Misc is the secondary category
<MTElse>
Misc is neither a primary not secondary category
</MTElse>
</MTIfCategory>
</MTElse>
</MTIfCategory>


