I'm working on a site using MT for (among other things) a client's news blog. Today's dilemma was that entries would be either internal PR pieces or synopses of external mentions with a link, and I wanted to allocate one of the fields as a place where the end user would simply put the URL for the external story, then, in the template, have an href pointing to <$MTThatField$> only if that field had been populated.
My first thought was to use the extended entry field, because there's that handy IfExtended tag. Of course that didn't work, because we have to leave the entries set to 'convert line breaks' for the non-tech end users who don't know how to make tags (and that's okay; they pay me to do it for them), which resulted in hrefs pointing to "<p>http://kalsey.com/2002/07/smartbody_plugin/</p>".
My second idea was to use the excerpt field because it doesn't create breaks. All I needed was an on/off switch. I googled 'IfExcerpt' and came across Adam Kalsey's SmartBody plugin, which worked out perfectly, after a few mishaps.
What I started out with:
<$MTEntryBody$>The first problem was one already mentioned in the comments -- that when you use the MTEntrySmartBody tag it overrides the 'convert line breaks' and removes them from all the fields and leaves you with one big, ugly paragraph.
<MTEntrySmartBody>
<$MTEntryIfExcerpt$>
<a href="<$MTEntryExcerpt$>">Click here to read the full story</a>
</MTEntryIfExcerpt>
Paragraph 1 Paragraph 2rather than
Paragraph 1Kalsey suggests using Brad Choate's format breaks plugin, but I decided to try something else first.
Paragraph 2
Turns out that using a close tag -- </MTEntrySmartBody> -- lets the line breaks show up in the other fields.
<$MTEntryBody$>The problem now was that, while it was making a correct link and breaking where I wanted it to, it was also printing the full link URL above the link text:
<MTEntrySmartBody>
<$MTEntryIfExcerpt$>
<a href="<$MTEntryExcerpt$>">Click here to read the full story</a>
</MTEntryIfExcerpt>
</MTEntrySmartBody>
Paragraph 1
Paragraph 2
http://kalsey.com/2002/07/smartbody_plugin/
Click here to read the full story
<$MTEntryBody$>results in:
<$MTEntryIfExcerpt$>
<a href="<$MTEntryExcerpt$>">Click here to read the full story</a>
</MTEntryIfExcerpt>
Paragraph 1(I should probably note here that I'm using MT 2.64 and have no idea if any of this is true with older versions.)
Paragraph 2
Click here to read the full story
I also modified the SmartBody plugin to include an IfTitle tag, which works just like MTEntryIfExcerpt, except you use MTEntryIfTitle. See Kalsey's site for installation instructions.
Examples:
Algonquin in the News
Don Harlow Reviews -- IfTitle for thumbnail, IfExcerpt for trailer link, IfExtended for pull quote