Chapter Utility
MTIfNonZero
A conditional tag that displays its contents if the tag specified with the tag attribute has a value that is not numerically equal to zero. If you want to test for an empty string instead, please use MTIfNonEmpty.
Attributes:
tag- The tag name to evaluate (with or without the MT prefix)
Other attributes are possible. See third example below.
Examples:
The following prints "This blog has comments!" if MTBlogCommentCount is not 0:
<MTIfNonZero tag="BlogCommentCount">
This blog has comments!
</MTIfNonZero>
As with all conditional tags, you can use the MTElse tag inside of MTIfNonZero to print something if the value of the tag is zero. Here's a brief example that you might use in the entry footer of your main index:
<MTIfNonZero tag="EntryCommentCount">
<a href="<$MTEntryPermalink$>#comments">
Comments (<$MTEntryCommentCount>)
</a>
<MTElse>
<MTIfCommentsAccepted>
<a href="<$MTEntryPermalink$>#comments">
Leave a comment
</a>
</MTIfCommentsAccepted>
</MTElse>
</MTIfNonZero>
Finally, if you are testing the value of a tag that has one or more attributes, those attributes can be used with MTIfNonZero as well. So, for example, to test
<$MTEntryFlag flag="convert_breaks"$>
you do the following:
<MTIfNonZero tag="EntryFlag" flag="convert_breaks">
Text formatting is being applied to the entry <$MTEntryTitle$>.
</MTIfNonZero>
Related topics:
For more details see the relevant section of Chapter 8 in the Users and Administrators Guide entitled "Conditional Tags".
You can download the Users and Administrators Guide here.


