Web Development » How to create a RSS feed with SilverStripe

How to create a RSS feed with SilverStripe

The greatest thing about creating RSS feeds with SilverStripe is that you can pretty much use any of your data, since all you really need is a DataObjectSet.

Here's my 2 second sample of an RSS feed:

function rss(){
        $articles = SiteTree::get('Page',"Status = 'Published'",'Created DESC');
        $rss = new RSSFeed($articles, '/rss', "Drop The Nerd :: RSS Feed", "", "Title", "Content", "DropTheNerd");
        return $rss->outputToBrowser();
    }

You can, of course, setup as many RSS feeds as you'd like. Just remember to add in an Auto Discovery meta tag:

<link rel=”alternate” type=”application/rss+xml” title=”Drop The Nerd RSS Feed” href=”http://dropthenerd.com/rss” />

Comments