WordPress Goodies with InlineRSS

Christmas is over, but I thought I might share a few of the scripts used on this site with you anyway. The key is an incredibly useful plugin called inlineRSS that pulls everything you throw at it into your site. You only need some XSLT magic. Since XSLT isn’t everyone’s strength, just copy my files:

  1. Let’s start with the simplest transformation, pulling the number of people who have bookmarked your post on del.icio.us. There are two components: one line of PHP code to insert the result in the footer of a page (found in template file single.php), and a few lines of XSLT for the transformation:

    1. <?php inlineRSS(
    2. 'delicious-incoming-' . $id,
      'http://feeds.delicious.com/rss/url?url=' . get_permalink(), 60, 'inline-rss-linked.xslt');
    3. ?>

    The function inlineRSS() takes four arguments: the filename where you want to cache the result, the feed URI, the time to cache in minutes, and the filename of the transformation stylesheet. The latter has to be in the same directory as inlineRSS.php (the plugin).

    1. <xsl:template match="/rdf:RDF">
    2. <xsl:if test="count( rss:item ) &gt; 0">
    3. Saved by <span class="linked-in"><xsl:value-of select="count( rss:item )" /></span> other people.
    4. </xsl:if>
    5. </xsl:template>

    Download: inline-rss-linked.xslt

  2. In the sidebar of this blog you see a section “current reading” which displays my latest five del.icio.us entries I have tagged with show-in-blog. Because I’m too lazy to add a description on del.icio.us there is just the title and the tags, minus “show-in-blog.” Here is the code for sidebar.php:

    1. <?php inlineRSS(
    2. 'delicious-links',
      'http://feeds.delicious.com/rss/ your-delicious-name/show-in-blog', 60, 'inline-rss-delicious.xslt');
    3. ?>

    Of course “your-delicious-name” needs to be replaced. ;)

    Download: inline-rss-delicious.xslt

  3. Finally there is a list of my upcoming events, including microformatted semantic information. The XSLT is a little longer, but not really complicated. You just need to replace the upcoming ID with your own.

    1. <?php inlineRSS(
    2. 'upcoming',
      'http://upcoming.yahoo.com/ syndicate/v2/ my_events/ 123456', 60, 'inline-rss-upcoming.xslt');
    3. ?>

    Download: inline-rss-upcoming.xslt

I’d like to point out that this is certainly not the only, and perhaps not even the best way to implement feeds into your site, but it’s pretty convenient once you’ve installed inlineRSS.

Chris Heilmann approaches the issue with a client side plugin to distribute tasks from the server to the client. His JavaScript is insofar unobtrusive as the list of inline del.icio.us links is replaced with an external link to his del.icio.us category, but then you give away the responsibility that the list is accessible as well. That’s why I would prefer a server side solution.

Ed Eliot has written a script to create a very pretty server side del.icio.us badge that I highly recommend, but it’s not as universal as the inlineRSS plugin, and it’s not a WordPress plugin to begin with (the same applies to his neat SimpleRSS script). But both Chris’ and Ed’s solutions are decent alternatives to take into consideration.

One Response to ‘WordPress Goodies with InlineRSS’

  1. Martin Kliehm

    Please note that del.icio.us has changed the URIs for their feeds. They are no longer del.icio.us/rss/, but feeds.delicious.com/rss/. Also the returned XML has changed a little. In inline-rss-delicious.xslt it’s now rdf:resource, not just resource.