SeeAllRSSChanges

Summary: Add date to RSS feed
Version:
Prerequisites:
Status:
Maintainer:
Category: RSS

Problem

My RSS Reader seems to order the feed by title itself without looking at the date. So it misses recently updated changes to pages that are already listed in the feed. The problem appears when using FeedReader, which is quite popular.

Because RSS can be used by authors and admins to monitor changes to their wikis, I think a fix is necessary.

Solution

The easiest way is to add the date to the title of the RSS, so it is hopefully unique.

Implementation

Create a rss.php in your local/ directory and include it from your config.php.

 
<?php if (!defined('PmWiki')) exit();

### RSS 2.0
  $RssItemFmt = '
        <item>
          <title>$FullName / $RssItemPubDate</title>
          <link>$PageUrl</link>
          <description>$RssItemDesc</description>
          <dc:contributor>$RssItemAuthor</dc:contributor>
          <dc:date>$RssItemPubDate</dc:date>
        </item>';

if ($action=='rdf') {
  $RssItemFmt = '
      <item rdf:about="$PageUrl">
        <title>$WikiTitle - $Group.$Name / $RssItemPubDate</title>
        <link>$PageUrl</link>
        <description>$RssItemDesc</description>
        <dc:date>$RssItemPubDate</dc:date>
      </item>';
}
?>

Comments

The correct element for Rss 2.0 to use seems to be <guid>:

 


### RSS 2.0
  $RssItemFmt = '
        <item>
          <title>$Title </title>
          <link>$PageUrl</link>
          <guid>$PageUrl-$RssItemPubDate</guid>
          <description>$RssItemDesc</description>
          <dc:contributor>$RssItemAuthor</dc:contributor>
          <dc:date>$RssItemPubDate</dc:date>
        </item>';

We choose to make the rss feed look like the RecentChanges page by modifying the scripts/rss.php in this way.

Are there any plans to make this into a complete 'recipe'? I haven't been able to get this working in its current form.
James F Mason


Globally the idea is good. But with the new release, it is the script feeds.php which is used and the modification to do is something like that :

SDVA($FeedFmt['rss']['item'], array(
  '_start' => "<item>\n",
  '_end' => "</item>\n",
  'title' => '{$Group} / {$Title} @ $ItemISOTime', /* modified part */
  'link' => '{$PageUrl}',
  'description' => '$ItemDesc',
  'dc:contributor' => '{$LastModifiedBy}',
  'dc:date' => '$ItemISOTime',
  'enclosure' => 'RSSEnclosure'));

To day I have not succeeded to do a clean patch (in config.php for instance) and I have directly patched the feeds.php files. Very ugly !

The method functions properly with FeedReader and Google Reader.

Coming from the news: thanks Pm ! It's enough to insert:

$FeedFmt['rss']['item']['title'] = '{$Group} / {$Title} @ $ItemISOTime';

in the local/config.php file.

JDem

Contributors