Category Tags
Category tags display information about your weblog categories.
Container Tags
- MTCategories:
<MTCategories>
- A container tag representing a list of the categories in your weblog. For each category, you can use any of the tag variables below; in addition, you can use an
<MTEntries> tag to display information about each of the entries in this category.
For example, this will display a link to each of your categories, each followed by a list of titles of the posts in that category:
<MTCategories>
<MTBlogIfArchives archive_type="Category">
<a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a>
<MTElse><$MTCategoryLabel$></MTElse>
</MTBlogIfArchives>
<br />
<MTEntries>
<$MTEntryTitle generate="1"$>
</MTEntries>
<br /><br />
</MTCategories>
When a category does not contain any posts, by default that category will not be included in the list of categories; this is the default behavior because it mirrors the behavior of <MTArchiveList>. Note that this is advised if you are including links to your category archive pages, because archive pages are not generated for empty categories. Thus, the archive link for an empty category will be a broken link.
If you would like to override this default behavior, you can provide this tag with the show_empty attribute. For example, this will display a list of all of your categories, even those that are empty:
<MTCategories show_empty="1">
<$MTCategoryLabel$>
</MTCategories>
- MTEntryIfCategories:
<MTEntryIfCategories>
- A conditional container tag that will only display its contents if the weblog post is assigned to one or more categories.
If you have some code that you would like to display only if the post is assigned to a category - such as category information - then wrap the code in MTEntryIfCategories container tags.
- MTEntryCategories:
<MTEntryCategories>
- A container tag that loops through each of the post's categories and displays information about them.
For example, this will display a list of all the categories that a post is assigned to:
<MTEntryIfCategories>in <MTEntryCategories glue=", "> <MTBlogIfArchives archive_type="Category"> <a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a> <MTElse><$MTCategoryLabel$></MTElse> </MTBlogIfArchives></MTEntryCategories></MTEntryIfCategories>
Variable Tags
- MTCategoryID:
<$MTCategoryID$>
- the numeric ID of the category.
- MTCategoryLabel:
<$MTCategoryLabel$>
- the category label
- MTCategoryArchiveLink:
<$MTCategoryArchiveLink$>
- a link to the archive page for this category. This only works if you have enabled
Category archiving for your weblog; if you have not, you will get an error message when rebuilding your pages.
- MTCategoryCount:
<$MTCategoryCount$>
- the number of entries in this category.
- MTCategoryDescription:
<$MTCategoryDescription$>
- the description for this category, if one has been set.
- MTCategoryID:
<$MTCategoryID$>
- the internal ID number for the category.
- MTCategoryTrackbackLink:
<$MTCategoryTrackbackLink$>
- if your category is set up to accept trackbacks, this will display the trackback URL that people can ping.
Other Examples
Display a list of the categories:
<h2>Categories</h2>
<ul>
<MTCategories>
<MTBlogIfArchives archive_type="Category">
<li><a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a></li>
<MTElse>
<li><$MTCategoryLabel$></li>
</MTElse>
</MTBlogIfArchives>
</MTCategories>
</ul>
Copyright © 2003-2005 Six Apart