<$mt:CategoryCount$>

The number of published entries for the category in context.

Attributes

All <mt:CategoryCount> attributes are optional. The most common attributes are:

singular

Allows special formatting for when the number of published entries in the category is equal to 1.

<$mt:CategoryCount singular="1 entry">

plural

Allows special formatting for when the number of published entries in the category is greater than 1.

<$mt:CategoryCount plural="# entries">

none

Allows special formatting for when the number of published entries in the category is 0 (zero).

<$mt:CategoryCount none="No entries">

or

<$mt:CategoryCount none="None">

Example

List categories containing entries with a count:

<ul>
<mt:Categories>
    <li>
        <a href="<$mt:ArchiveLink type="Category"$>"><$mt:CategoryLabel$></a> (<$mt:CategoryCount$>)
    </li>
</mt:Categories>
</ul>

List categories named “Bug Fixes” along with the number of published articles:

<mt:Categories>
<mt:If tag="CategoryLabel" eq="Bug Fixes">
 <mt:SetVarBlock name="cat_news_count"><$mt:CategoryCount singular="1 article" plural="# articles" none="No articles"$></mt:SetVarBlock>
 <$mt:CategoryLabel$> has <$mt:var name="cat_news_count"$>.
</mt:If>
</mt:Categories>
This page was last updated on 2010-06-18, 12:59.

2 Notes

All counts take the following additional (undocumented) attributes:

           singular="1 sometext" plural="# sometext" none="No sometext"

Where sometext is whatever you want.

Thus, this could be:

and it will say "1 entry", "2 entries" (or whatever number of entries it finds) or "No entries"

The technique that Gautam suggested works. I added the attributes to the documentation and provided an additional example.

Leave a note

Have a question? Please use the MT Forums. Notes submitted on documentation should pertain to tips & hints regarding documentation. Your note may be removed once its contents have been integrated into the body of the page.