sfFeed2Plugin patch
Saturday, January 5th, 2008I wrote a small patch for sfFeed2Plugin (verson 0.9.4) to get feed’s generator field and comment feeds for each post.
The generator is an identificator of software that generated feed. It is quite obvious and both RSS and Atom formats support it.
However, comment feeds are a little bit more tricky.
In Atom you get something like that:
<entry>
...
<link rel='replies' type='text/html'
href='http://blog.example.com/post-title/#comments'
title='Comments'/>
<link rel='replies' type='application/atom+xml'
href='http://blog.example.com/post-title/feed/'
title='Comment feed'/>
...
</entry>
So we need replies link which has a mime type application/atom+xml.
In RSS it is more straighforward:
<item>
...
<wfw:commentRss>
http://blog.example.com/post-title/feed/
</wfw:commentRss>
...
</item>
We simply get the wfw:commentRss field.
So how to use patched sfFeed2Plugin?
It is really easy, there is one additional method in sfFeed class called getGenerator(), and one in sfFeedItem class called getCommentFeed():
<?php
$feed = sfFeedPeer::createFromWeb($url);
echo $feed->getGenerator()."\n";
foreach($feed->getItems() as $item) {
echo $item->getCommentFeed()."\n";
}
?>
How to apply the patch?
$ cd sfFeed2Plugin/
$ patch -p1 < sfFeed2Plugin-094-mauser.patch


