Questions answered by this recipe
How can I display an RSS feed in a PmWiki page?
These instructions are still in draft!
This recipe is based (heavily) on Cal Demaine's WordPress plugin "inlineRSS" available from his website.
The RSS feed is fetched (from its URL or a cache) and transformed to PmWiki markup using an XSLT transformation. A default transformation is supplied.
+ PMinlineRSS |-- PMinlineRSS.php |-- PMinlineRSS.xslt |-- altRSS.xslt
Copy the directory into your cookbook directory on your server and then add the following to your localization file
(altRSS.xslt simply provides an example of an alternate XSLT file)
Now you're ready to go.
The full markup is
(:inlineRSS feed="http://feeds.feedburner.com/ilounge" cachename=ilounge cachetime=15 altXSLT="altRSS.xslt":)
The parameters are:
The URL of the RSS feed. Best left quoted I think, though not sure exactly why.
An optional parameter. If specified then the feed will be written to a cache file the first time it is read and thereafter the feed contents will be read from this cache unless it is older than the time specified on the cachetime= parameter. Ensure that this is set to a unique value if you include multiple feeds on your site. See Notes below for detail on how the caching is done.
An optional parameter. This defines the number of minutes old the cache must be before the feed will be re-fetched from the URL. If you do not specify cachetime= but do specify cachename= then the default is 30 minutes. Note that it is possible to include the same feed in two different places with different time-outs and everything will work fine.
An optional parameter which specifies the name of the XSLT file used to transform the feed to PmWiki markup. If not specified, the default XSLT file (PMinlineRSS.xslt) is used. All XSLT files must reside in the cookbook/PMinlineRSS/ directory. The default file shows the channel name as a heading (level 3) and this is a link to the web site that provides the feed. All items are then listed in a bulleted list, each item title being a link to the item.
You may edit a few lines in PMinlineRSS.php if you wish, though this would only seem necessary if there are naming conflicts with the cache files. The lines are commented and thus self explanatory, at the top of the file:
$cookbookpath = 'cookbook/PMinlineRSS/'; // Path to directory containing XSLT files $cachepath = 'pub/'; // Path to directory for cache files $fileprefix = 'cache_'; // What cache file names get prefixed with $xsltfile = 'PMinlineRSS.xslt'; // The default xslt file
Note that cache file names are built from $cachepath + $fileprefix + cachename + ".xml"
You can of course replace the XSLT file (or better still, add your own and use altXSLT to invoke it) but I recommend you start from the default file as there are some big gotchas with RSS versus RDF feeds which took me a while to master!
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".
- 2016-05-09 I changed the Markup() call to a Markup_e() call to solve PHP 5.5 issues. See version 2016-05-09Δ. Peter Bowers May 09, 2016, at 06:06 AM
- 2015-02-07 I made some changes to make this work (maybe change in PHP version?) and uploaded a new versionΔ Peter Bowers February 07, 2015, at 01:49 PM
- Some of these changes were actually on the talk page, but I didn't see them until after fixing them. That's why I figured it's better to upload a new version.
See discussion at InlineRSS-Talk