RSSOutput
Questions answered by this recipe
Can we write wiki pages into an RSS-Feed? Yes, we can. :-)
How can I build an RSS-Feed from my wiki pages?
Description
Creates RSS-Feed from wiki pages with pagelist directive
Notes
I needed that for our intranet. We needed a simple way for all users to see recent changes.
Installation
First of all put this in your local/config.php. You also can write it in an include file.
# change settings for RSS Feed if((FmtPageName('$Group', $pagename) == "RSS") and ($Action != "edit")) { # Change HTML-Tags SDV($PageTextStartFmt, "\n\n"); SDV($PageTextEndFmt, "\n"); Markup('RSSP', '<<vspace>', '/<p.*?>/', ''); Markup('RSSPEnd', '<<vspace>', '/<\/p>/', ''); Markup('RSSCode', '<<vspace>', '/<code.*?>/', ''); Markup('RSSCodeEnd', '<<vspace>', '/<\/code>/', ''); # Change style path $Skin = 'rss'; # simple markup for a counter $FmtPV['$RSSCounter'] = 0; function RSSCountup() { global $FmtPV; $FmtPV['$RSSCounter'] = $FmtPV['$RSSCounter']+1; return sprintf("RSS%04d", $FmtPV['$RSSCounter']); } Markup("rsscounter", 'directives', '/\(\:rsscount\:\)/e', 'Keep(RSSCountup())'); # Enable XML Tags. Based on recipe enableHTML function RSSEnableXML($tag) { Markup( "xml-$tag", '>{$var}', '/<(\/?('.$tag.')(?![a-z!])(([\'"]).*?\4|.*?)*?)>/ie', 'Keep(PSS(\'<$1>\'))'); } RSSEnableXML('item|title|description|link|author|guid|pubDate|b'); }
Now you need a new template for that category in the folder rss.
<?xml version="1.0" encoding="iso-8859-1"?> <rss version="2.0"> <channel> <title>My own feed</title> <link>http://yourhost.com/rss.xml</link> <description>This are the recent changes.</description> <language>de-de</language> <copyright>Mr. Right</copyright> <pubDate></pubDate> <image> <url>$SkinDirUrl/my_logo.gif</url> <title>My own feed</title> <link>http://yourhost.com/rss.xml</link> </image> <!--PageText--> </channel> </rss>
I used iso-8859-1 and language de-de for german umlauts.
You can change it.
For more Details on RSS look in to wikipedia. :-)
Now you create a startpage/homepage for that category with a pagelist for the last recent changes.
(:if false:)(:nolinkwikiwords:) [[#rss]] (:template each:)<item>\ <title>{=$Title}</title>\ <description></description>\ <link>http://yourhost.com{=$PageUrl}</link>\ <author>{=$LastModifiedBy}</author>\ <guid>(:rsscount:)</guid>\ <pubDate>{=$LastModified}</pubDate>\ </item> [[#rssend]] (:if:) (:pagelist trail=Site.AllRecentChanges group=-Category,-Templates count=-10 order=time wrap=inline fmt=#rss:)
See Also
XML-Tag usage based on EnableHTML.
Contributors
User 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.