HOW-TO: Customize RSS Syndication with xml.rss.renderWithTemplate
Radio UserLand offers some incredible possibilities for displaying RSS feeds that are readily available on the web with your own RU weblog. Here is a list of popular sites . This page will help you learn how to use the xml.rss.renderWithTemplate verb built into RU that makes displaying syndicated RSS feeds a snap.
xml.rss.renderWithTemplate gives you much more flexibilty than xml.rss.viewRssBox if you want to do a lot of custom formatting of the feed on your site. This document assumes that you have already read through the documention for the xml.rss.renderWithTemplate verb, and have a basic idea what it does. This How-To expands on that documentation and gives you a few examples of custom formatting with this verb.
Subscribing To RSS Feeds
In order for you to render RSS feeds, you first must subscribe to them. Though you will see the URL of an RSS feed in the xml.rss.renderWithTemplate macro, it does not call the feed. It is looking for a table in the aggregatorData.root (a file used by Radio UserLand).
When you install Radio UserLand, you will find that a number of popular services have already been subscribed for you. You can remove any of the subscriptions that are provided, or add your own. On many RU and Manila-managed sites, you will see the XML coffee cup (at right). If you are running RU on your desktop, simply clicking on this graphic will add that RSS feed to your subscriptions. Clicking on the graphic to the right will subscribe you to my "Radio Keola" RSS feed. If you know the URL of the RSS feed you want to subscribe to, you can manually enter it on your subscriptions page.
All of the following examples work. I've copied each macro from a web browser into RA, and it processed the macros fine. The only error you should see is if you try to use them without having subscribed to the RSS feeds in the macro.
Dictionary.com Word of the Day
You can have the Dictionary.com word of the day appear on your page - the caveat being that it will only update when you run Radio Userland. So if you don't use RU for a few days, your site will continue the display the WOTD of the last used RU. If you have not already subscribed to WOTD, click on the XML coffee cup to the left of the link above. The link itself is generated by the macro displayed below.
[Macro error: Can't find a sub-table named "http://www.dictionary.com/wordoftheday/wotd.rss".]
<%system.verbs.builtins.xml.rss.renderWithTemplate (@aggregatorData.services.["http://www.dictionary.com/wordoftheday/wotd.rss"], "{items ()}", "{itemText()}", "Dictionary.com Word of the Day", 1, "HST")%>
|
Wired News Last Updated - 6/29/2003
|
This is the Wired News feed in an unordered list. The macro for this appears below:
<%system.verbs.builtins.xml.rss.renderWithTemplate (@aggregatorData.services.["http://www.wired.com/news_drop/netcenter/netcenter.rdf"], "<b>{sourceTitle()}</b><BR><i>Last Updated - {updatetime()}</i><p><UL>{items ()}</UL>", "<LI>{itemText()}", "Wired News", 4, "HST")%>
Digital Photography Review (dpreview.com)
This example above uses a bit of fancier table formatting with two columns and adds a graphic before each item. Macro appears below. Note that you must use forward slashes if you include quotation marks in the macro, as I have to specify colspan, class, size and alignment values.
|
||||||||||
<%system.verbs.builtins.xml.rss.renderWithTemplate (@aggregatorData.services.["http://www.dpreview.com/news/dpr.rdf"], "<table border=\"0\" bgcolor=\"antiquewhite\" width=\"500\" cellpadding=\"3\"><TR><TD colspan=\"2\" class=\"small\"><B>{sourceTitle()}</b><BR><i>Last Updated - {updatetime()}</i></TD></TR>{items ()}</TABLE>", "<TR><TD VALIGN=\"TOP\"><img src=\"http://static.userland.com/shortcuts/images/qbullets/movie.gif\" width=\"13\" height=\"11\"></TD><TD VALIGN=\"TOP\" class=\"small\">{itemText()}</TD></TR>", "Digital Photography Review (dpreview.com)", 4, "HST")%>