|
Cookbook /
InlineRSSSummary: Allows insertion of an RSS feed's contents into a PmWiki page.
Version: 1.0
Prerequisites: None
Status: DRAFT
Maintainer: zkarj
Questions answered by this recipeHow can I display an RSS feed in a PmWiki page? DescriptionThese instructions are still in draft! OverviewThis 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. InstallationDownload the PMinlineRSS.zipΔ file and extract locally. It contains the following files + PMinlineRSS |-- PMinlineRSS.php |-- PMinlineRSS.xslt Copy the directory into your cookbook directory on your server and then add the following to your localization file
include_once('cookbook/PMinlineRSS/PMinlineRSS.php');
Now you're ready to go. UseThe full markup is (:inlineRSS feed="http://feeds.feedburner.com/ilounge" cachename=ilounge cachetime=15 altXSLT="myxslt.xslt":) The parameters are: feed="" cachename= cachetime= altXSLT="" NotesCustomizingYou 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! Release Notes
CommentsIt's working well, but I had to replace "directive" by "directives" to avoid the parsing error (and with <fulltext instead of directives, I was able to use my custom markup and to get the correct list output). The xslt file may also use utf-8 by default. The patch to get a custom number of posts should be included as well - Farvardin Hi, work great! but is there a way to choose the number of post you want to show? touann - 12/07/2007 WebBird - 12/06/2010 Here's a quick mod to achieve this: FIND:
$p_altXSLT = $args['altXSLT']; AFTER, ADD: $p_maxitems = $args['maxitems']; FIND:
if (empty($xslt_result)) {
$xslt_result = "Horrific XSLT error - $casualname returned empty - verify $cachepathname is a valid XML file and check logs.\n";
}
AFTER, ADD:
if ( $p_maxitems && is_numeric($p_maxitems) && $p_maxitems > 0 && $p_maxitems < 1000 ) {
$temp = preg_split( "#\r?\n#", $xslt_result );
$result = implode( "\n", array_slice( $temp, 0, $p_maxitems+1 ) );
}
else {
$result = $xslt_result;
}
REMOVE:
$result = $xslt_result; Use "maxitems=<number>" to restrict the number of items to show. WebBird - 12/06/2010 When I attempt to create a page with an {:inlineRSS:) markup, I get a white screen, blank except for the words "No valid XSLT processor found." I installed everything exactly as it was written here and have tried pointing to several different feeds to see if any worked. Mike - 8/30/2007 I am pretty sure this requires PHP5 with the XSLT functionality enabled. I am getting the same error as above. Scott - 2/18/08 Works with PmWiki 2.1, PHP4 and XSLT. BM - 10/10/08 Could someone link to a tutorial on how to get XSLT working with PHP? Richard - 8/13/09 See AlsoContributorsUser notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |