Movable Type Enterprise Documentation

« MTIfNonEmpty | Up | MTInclude »

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.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or question. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Enterprise Support.

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.