If you have setup a sideblog/linkblog then you will notice that the rss it generates is rather annoying. If you look at the RSS through an aggregator such as Bloglines and you click on the title of the entry, it takes you to the entry permalink. This is fine with most blogs but in sideblogs its rather annoying. I would much prefer being taken to the page in question rather than the entry permalink. To understand what I mean look at MovableBLOG Asides rss file, you will see the link element links to the page he is talking about, click the title it will not take you to the entry permalink. This means that you will need to extract the uri specified in the href tags.

To accomplish this you will need:

  1. A sideblog setup where the link (a href tag) is in the entry body, and the description is in the extended entry
  2. Brad Choate's Regex Plugin
  3. You to be using MT's quickpost tool - if you do not use it, you must make sure all your hyperlinks are in the format <a title="xxx" href="xxx">xx</a>

Add the following code to the tops of all your rss files (in the RSS 2.0 file you may need to put it underneath the xml tag)

<MTAddRegex>s|<a .*?href=\"(.*)\".*?>(.*)</a>|$1|g</MTAddRegex>

Atom Index

Find in your template the following:

<link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
and replace it with
<link rel="alternate" type="text/html" href="<$MTEntryBody regex="1" convert_breaks="0"$>" />

RSS 1.0 and 2.0 Index

Find in your template:

<link><$MTEntryPermalink encode_xml="1"$></link>

and replace it with

<link><$MTEntryBody regex="1" encode_xml="1" convert_breaks="0"$></link>

And there you have it, when you view your RSS file in a Aggregator (eg BlogLines) you will see that clicking the

4 Comments

elise said:
on Aug 1, 2004 10:58 PM | Reply

Hi Arvind, Thanks for the tip, it works great!

Neil T. said:
on Aug 5, 2004 6:00 PM | Reply

I used the MTCollect plugin to achieve the same thing. I used this code:

<MTCollect tags="a">
<MTCollectThis><$MTEntryBody$></MTCollectThis>
<MTCollected lastn="1"><link><$MTCollectedAttr attr="href"$></link></MTCollected>
</MTCollect>

MTCollect is a very powerful plugin that I use for things like showing how many images there are in a post. I once also used it to list links and citations in posts. You could probably do all that with MTRegex but you don't need to know how to do regular expressions.

Arvind Satyanarayan said:
on Aug 5, 2004 8:25 PM | Reply

Thanks Neil, the regex is quite hard to understand for someone that doesn't know perl, that looks much easier !

Michael Romero said:
on Nov 1, 2004 10:28 AM | Reply

You fixed one of the things that MOST bothered me about the sideblog concept. Thanks a bunch.

Leave a comment

Preview