Revealing your sources
Question:
Gordon Bonnar writes:
I’ve got an interesting one for you. I am sure this can be done with the Macro and Regex plug-ins. I am just not sure how.
I always use the cite element and the title element in my blockquotes. What I would like is for a link to appear at the bottom right within the blockquote pointing to the cite URL with the text of the title attribute. Do you think this is doable?
Brad Answers:
Absolutely.
<MTMacroDefine ctag="blockquote"><MTMacroTag rebuild="1"> <MTMacroContent regex="s|</p\x3e\s*$||s"> <MTIfNotEmpty expr="[MTMacroAttr name='cite']"> [<a href="<MTMacroAttr name="cite">"><MTMacroAttr name="title"><MTIfEmpty expr="[MTMacroAttr name='title']"><MTMacroAttr name="cite"></MTIfEmpty></a>] </MTIfNotEmpty></p></blockquote></MTMacroDefine>
That should do it. You can collapse some of the lines to avoid extra line breaks in the output. What this will do is add a “[hyperlink]” at the end of the blockquote. The hyperlink will use the ‘cite’ attribute for the URL and the title attribute for the text of the link. This will only get added if the ‘cite’ attribute is present. And it will default to the ‘cite’ attribute as the title of the link if the title attribute isn’t present. (Note: this solutions requires MT-Macro, MT-IfEmpty and MT-Regex.)
Now this also assumes that you use paragraph tags within the blockquote (as it appears you’re doing on your site). This will strip off the last closing </p> and place a new one following the addition. Kind of a hack, but it should work.
If you don’t want to rely on the paragraph hack just described, you can place the citation in it’s own <div> block and use CSS to style it to your liking:
<MTMacroDefine ctag="blockquote"><MTMacroTag rebuild="1">
<MTMacroContent>
<MTIfNotEmpty expr="[MTMacroAttr name='cite']">
<div class="citationsrc">
<a href="<MTMacroAttr name="cite">"><MTMacroAttr
name="title"><MTIfEmpty
expr="[MTMacroAttr name='title']"><MTMacroAttr
name="cite"></MTIfEmpty></a>
</div>
</MTIfNotEmpty></blockquote></MTMacroDefine>
[ Movable Type ] / posted @ Tuesday, March 18, 2003 11:32 AM EST