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:
-
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:<?php inlineRSS(
'delicious-incoming-' . $id,
'http://feeds.delicious.com/rss/url?url=' . get_permalink(), 60, 'inline-rss-linked.xslt');?>
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 asinlineRSS.php
(the plugin).<xsl:template match="/rdf:RDF">
<xsl:if test="count( rss:item ) > 0">
Saved by <span class="linked-in"><xsl:value-of select="count( rss:item )" /></span> other people.
</xsl:if>
</xsl:template>
Download:
inline-rss-linked.xslt
-
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 forsidebar.php
:<?php inlineRSS(
'delicious-links',
'http://feeds.delicious.com/rss/ your-delicious-name/show-in-blog', 60, 'inline-rss-delicious.xslt');?>
Of course “your-delicious-name” needs to be replaced.
Download:
inline-rss-delicious.xslt
-
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.
<?php inlineRSS(
'upcoming',
'http://upcoming.yahoo.com/ syndicate/v2/ my_events/ 123456', 60, 'inline-rss-upcoming.xslt');?>
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.
Please note that del.icio.us has changed the URIs for their feeds. They are no longer
del.icio.us/rss/
, butfeeds.delicious.com/rss/
. Also the returned XML has changed a little. Ininline-rss-delicious.xslt
it’s nowrdf:resource
, not justresource
.