|
Cookbook /
FeedLinksSummary: Add html-header links for auto-discovery of rss/atom feeds
Version: 0.03 (2006-03-19)
Status: Stable
Prerequisites: pmwiki-2.0
Maintainer: Hagan
Categories: RSS
Votes: 5
QuestionHow can I add links that will enable autodiscovery of my site's Atom and/or RSS feeds? AnswerThe feedlinks.phpΔ script adds RSS and Atom feed link tags in your pages' HTML Headers. Typical feed links look like this:
<link rel='alternate' title='Your Site : Main - RSS Feed'
href='http://example.com/wiki/Main/RecentChanges?action=rss'
type='application/rss+xml' />
<link rel='alternate' title='Your Site : Main - Atom Feed'
href='http://example.com/wiki/Main/RecentChanges?action=atom'
type='application/atom+xml' />
InstallationDownload feedlinks.phpΔ and place it to your cookbook/ directory, then insert the following line in your local/config.php file: include_once("$FarmD/cookbook/feedlinks.php");
SettingsBy default the script will produce RSS 2.0 and Atom links the site-wide AllRecentChanges page ($SiteGroup/AllRecentChanges). If you want to override the defaults you can pass settings to the script. For example, to advertise RSS 2.0 feeds by group, use
## Enable the feedlinks recipe, which adds HTML header links that enable
## "autodiscovery" of the site's Atom and/or RSS web feeds.
$EnableSitewideFeed = 0;
$EnableRssLink = 1;
$EnableAtomLink = 0;
include_once("$FarmD/cookbook/feedlinks.php"); # RSS 2.0 feeds by group
or to advertise RSS and Atom links to a sitewide feed at Main/AllRecentChanges instead of the default $SiteGroup/AllRecentChanges, use
## Enable the feedlinks recipe; Sitewide RSS 2.0 and Atom Feeds
$FeedLinkSourcePath = 'Main/AllRecentChanges';
include_once("$FarmD/cookbook/feedlinks.php");
NotesSteP 2009-09-14: I think the code needs changing to support setting feed source and title on a per-group basis. Replace these two lines $FeedLinkSourcePath = '$[$Group/RecentChanges]'; $FeedLinkTitleGroup = ' : $[$Group] -'; with SDV($FeedLinkSourcePath, '$[$Group/RecentChanges]'); SDV($FeedLinkTitleGroup, ' : $[$Group] -'); Releases
CommentsEnhancement request: It would be nice to be able to specify more than one feed in $FeedLinkSourcePath! --Tom, 18-Mar-2006 Tom, Try the new version, which you can run more than once. Just change the variable(s) in between.
## Enable the feedlinks recipe; Site.AllRecentChanges and Main.AllRecentchanges feeds
## "autodiscovery" of the site's Atom and/or RSS web feeds.
include("$FarmD/cookbook/feedlinks.php");
$FeedLinkSourcePath = 'Main/AllRecentChanges';
include("$FarmD/cookbook/feedlinks.php");
It's also easy to have both site-wide and by-group links now.
## Enable the feedlinks recipe, which adds HTML header links that enable
## "autodiscovery" of the site's Atom and/or RSS web feeds.
include("$FarmD/cookbook/feedlinks.php"); # Site-wide
$EnableSitewideFeed = 0;
include("$FarmD/cookbook/feedlinks.php"); # Per-group
--Hagan 2006-03-19 See Also
ContributorsUser notes +1: 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. |