I'm trying to get the Entry Summary of my movable type blog to display an image with the title formatted a certain way over the image (The image is tagged if it will be used for this purpose), and display the title another way if there is no image. However, I cannot get the else statement to work with MTEntryAsset as it should. If there is no EntryAssets tagged "homepage" with the type "image" it does nothing.
<mt:entryassets tag="homepage" type="image" limit="1">
<div class="image_entrie_header"><img src="<mt:assetthumbnailurl>"></div>
<h3 class="blog_entry_headingimg"><a href="<mtentrypermalink>"><mt:entryTitle></a></h3>
<mt:else>
<h3 class="blog_entry_heading"><a href="<mtentrypermalink>"><mt:entryTitle></a></h3>
</mt:entryassets>
I do not believe the EntryAssets tag supports <mt:Else>
, but you can achieve this with a little Movable Type logic.
With some simple tags, you would be able to do something like this:
<mt:If tag="EntryCategory">
<p>Filed under <$mt:EntryCategory$></p>
<mt:Else>
<p>Uncategorized</p>
</mt:If>
But since your block tag, EntryAssets, is a complicated tag taking several template tag modifiers, one of which is also called tag
, this won't work. We can fake it using Movable Type variables like this:
<$mt:Var name="asset_found" value="0"$>
<mt:EntryAssets tag="homepage" type="image" limit="1">
<$mt:Var name="asset_found" value="1"$>
Your code here
</mt:EntryAssets>
<mt:Unless name="asset_found">
Show this if none found
</mt:Unless>
Note the first line where we set the variable asset_found
to 0
is not strictly required by Movable Type, but it's good to reset the variable in case you use this block in multiple places in the same template.