Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » RSS feed items to pages

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 740 Views
  • LesC
    Community Member
    70 Posts

    RSS feed items to pages Link to this post


    Background: I've seen a few posts around using SimplePie and the RestfulService that show how to present RSS feed items on pages, and have seen WillR's response nearly a year ago for how to insert RSS entries as blog posts (http://silverstripe.org/archive/show/187016#post187016).

    Situation: I'm trying to grab a news feed and create pages from it (it's a stock news feed, but I'd like to be able to use it with any RSS feed). I have a FeedHolder class that shows a list of FeedEntry items (these are the pages I want to create), and have set it up so they can be manually created in the CMS.

    Problem: I understand that I need to first pull in the feed, then insert each feed as a page, but I'm getting a bit confused with his example and can't see how it should be creating entries. Once I get it creating entries, I'd like to call it every so often to update the entries from the feed.

    WillR's code from the aforementioned post:

    $feed = new RestfulService("URL OF RSS FEED");
    $conn = $feed->connect('');
    $msgs = $feed->getValues($conn, "status");

    $output = new DataObjectSet();
    foreach($msgs as $msg){
    foreach($feed as $feedItem) {
    $blog = new Blog_Entry();
    $blog->Title = "This is the Title"; // should come from $feedItem
    $blog->setDate(date("Y-m-d H:i:s",time()));
    $blog->publish("Stage", "Live");
    $blog->Author = "Author";
    $blog->Content = $feedItem->Content;
    $blog->ParentID = DataObject::get_one('BlogHolder')->ID;

    Can anyone point me in the right direction? Or even better show me what needs to be done to get it working?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.