Chapter Utility
MTIfNonEmpty
A conditional tag that displays its contents if the tag specified with the tag attribute returns a value (i.e. is not empty or null)
Note that a value of '0' is not considered a null value for this tag and will cause the its contents to be printed. If you want to test numerical return values, you should instead use MTIfNonZero.
Attributes:
tag- The tag name to evaluate (with or without the MT prefix)
Other attributes are possible. See third example below.
Examples:
The following will print the entry title as an h2 header if a title was given:
<MTIfNonEmpty tag="EntryTitle">
<h2><$MTEntryTitle$></h2>
</MTIfNonEmpty>
As with all conditional tags, you can use the MTElse tag inside of MTIfNonEmpty to print something if the value of the tag is empty. Here's a brief example that you might use in an MTEntries block to nicely handle entries without categories:
Category:
<MTIfNonEmpty tag="EntryCategory">
<$MTEntryCategory$>
<MTElse>
None
</MTElse>
</MTIfNonEmpty>
Finally, if you are testing the value of a tag that has one or more attributes, those attributes can be used with MTIfNonEmpty as well. So, for example, to test
<$MTEntryTitle remove_html="1"$>
you do the following:
<MTIfNonEmpty tag="EntryTitle" remove_html="1">
<title><$MTEntryTitle remove_html="1"$></title>
</MTIfNonEmpty>
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.


