if something exist do something

174 Views Asked by At

I have something like this:

<mt:Entries tags="@feature1" lastn="1">
<mt:EntryBody$>
</mt:Entries>

I would like to add an @test tag. If there is an entry that has an @test tag then show that entry. Otherwise show @feature1. Anyone know how I would go about that?

1

There are 1 best solutions below

0
On

Tested working in MT4.35:

<mt:entries tag="@test1" limit="0"><$mt:entriescount setvar="testFlag"$></mt:entries>
<mt:if name="testFlag">
    <mt:entries tags="@test1" limit="1">
    <$mt:entrytitle$>
    </mt:entries>
<mt:else>
    <mt:entries tags="@feature1" limit="1">
    <$mt:entrytitle$>
    </mt:entries>
</mt:if>

If the output format of the two cases is identical, there's a couple ways this could be compressed some, but I've left it verbose for clarity.