|
Cookbook /
RSSOutputSummary: RSS Output from a wikipagelist
Version: 0.9 2008-12-07
Prerequisites:
Status: BETA
Maintainer: Michael Selbmann
Categories: RSS
Questions answered by this recipeCan we write wiki pages into an RSS-Feed? Yes, we can. :-) DescriptionCreates RSS-Feed from wiki pages with pagelist directive NotesI needed that for our intranet. We needed a simple way for all users to see recent changes. InstallationFirst 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.
(: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 AlsoXML-Tag usage based on EnableHTML. ContributorsUser 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. |