Logic to implement: If Entry has an excerpt, use it; if it does not, return content in EntryBody.
This produces weird results:
<mt:If tag="EntryExcerpt" />if entry has excerpt, return it<mt:Else>do something else</mt:If>
I've gone through several combinations, with and without auto_generate no_generate. Can anybody offer a solution?
Reported on Movable Type 4.2
Tried this yet?
<mt:IfNonEmpty tag="EntryExcerpt">
<$mt:EntryExcerpt$>
<mt:Else>
<$mt:EntryBody$>
</mt:IfNonEmpty>
I considered this, but didn't touch IfNonEmpty, because it is documented as deprecated. Now that you mentioned it, I tried your code, and it returns the same result as simply using <mt:EntryExcerpt /> - that is, it will auto-generate an excerpt from EntryBody, if there is no excerpt.
I think there was a time when your code worked. I suppose that EntryExcerpt got neglected ever since mt:If was given more powers.
Come to think of it, it probably never worked, since EntryExcerpt auto-generates and is therefore never empty. This logic might work better with a custom field.
There was an interesting comment here by Jay Allen about the places EntryExcerpt is used.
(I actually don't like to use it, since it strips html out, and there may be links at the beginning of the entry.)
I also wish MT knew what a sentence or paragraph was.
Well, if you use <mt:If tag="EntryExcerpt" no_generate="1"> or the code in Dan Wolfgang's reply, then EntryExcerpt will evaluate to an empty value if there is no excerpt.
A little correction on my post above: It should read no_generate, not "auto_generate".
What do you mean by "links at the beginning of the entry"?
strips html, so when we use it on a multiblog custom index template aggregating topical posts from many bloggers (e.g.on Inauguration Day), using EntryExcerpt to keep its length manageable strips html that's in those first n words.
You need to use the no_generate flag to get what you want: http://www.movabletype.org/documentation/appendices/tags/entryexcerpt.html
<mt:EntryExcerpt no_generate="1" setvar="excerpt"> <mt:If name="excerpt"> <mt:EntryExcerpt> <mt:Else> <mt:EntryBody> </mt:If>I must have overlooked something else earlier today, because this works and I used a variant (<mt:If tag="EntryExcerpt" no_generate="1">) without seeing the correct result. Thanks for your input.