<mt:EntryCategories>
A container tag that lists all of the categories (primary and secondary) to which the entry is assigned.
This tagset creates a category context within which any category or subcategory tags may be used.
<mt:EntryCategories>
<!-- do something -->
</mt:EntryCategories>
Attributes ¶
glue ¶
If specified, this string is placed in between each result from the loop.
Examples ¶
List and link all entry categories:
<mt:Entries>
<MTEntryCategories glue=", "><a href="<$mt:ArchiveLink type="Category"$>"><$mt:CategoryLabel$></a></MTEntryCategories>
</mt:Entries>
If entry primary category label matches the label of the category in the loop, then make it bold:
<mt:Entries>
<$mt:EntryCategory setvar="entry_category"$>
<ul>
<MTEntryCategories>
<li><a href="<$mt:ArchiveLink type="Category"$>"><mt:If tag="CategoryLabel" eq="$entry_category"><strong><$mt:CategoryLabel$></strong><mt:Else><$mt:CategoryLabel$></mt:If></a></li>
</MTEntryCategories>
</ul>
<$mt:Var name="entry_category" value=""$>
</mt:Entries>
If entry category is in set (Explore, Savor, Inside, Offbeat, Celebrate), add category basename as a class and link to category archive.
<mt:Entries>
<mt:EntryCategories>
<mt:If tag="CategoryLabel" like="(Explore|Savor|Inside|Offbeat|Celebrate)">
<mt:SetVarBlock name="category_basename"> <$mt:CategoryBasename$></mt:SetVarBlock>
</mt:If>
</mt:EntryCategories>
<div class="post<$mt:Var name="category_basename"$>">
<mt:EntryCategories>
<mt:If tag="CategoryLabel" like="(Explore|Savor|Inside|Offbeat|Celebrate)">
<a href="<$mt:ArchiveLink type="Category"$>"><$mt:CategoryLabel$></a>
</mt:If>
</mt:EntryCategories>
<!-- more entry data here -->
</div>
<$mt:SetVar name="category_basename" value=""$>
</mt:Entries>
Gautam Patel
April 1, 2010 3:04 AM | Reply
A word of caution about the first example. It does not necessarily return a correct hierarchical listing of the entry's categories and is, therefore, not useful for generating breadcrumbs.
If you have nested categories, and you select a sub-category first and then its parent, this code will list them in the order in which they are selected.
So, if your categories are LITERATURE > Joyce, and you first select Joyce and then tick on LITERATURE, that's the order in which they get listed.
Gercek Karakus
replied to comment from Gautam Patel
April 20, 2010 6:20 AM | Reply
If you want to implement breadcrumbs, checkout Beau Smith's advanced breadcrumbs article: http://www.beausmith.com/mt/2009/10/advanced-breadcrumb-navigation.php