17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1093 Views |
-
RSS feed as blog posts

1 October 2008 at 9:01pm
I know there is a widget that posts RSS results in a side menu, so SilverStripe is clearly able to handle them, what I want however is for the RSS results to show up as a new blog post. is that possible?
And could anyone give me some pointers on how it's done? -
Re: RSS feed as blog posts

2 October 2008 at 1:17pm
I assume that the RSS feed comes from an external source and you want to create posts with them.. I did the same with my twitter feed. Got the feed data, and made objects from them so that I could sort / search all of them. Heres an outline of my code. You will need to put this somewhere eg Page.php -> Page_Controller
$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;
$blog->write();
}
}Thats the outline at least. This will do things like create the blog entry every time you look at the feed url (which is probably not wise) but thats how it would work
-
Re: RSS feed as blog posts

2 October 2008 at 7:23pm
Thanks for your help willr, at least now I have something to work with
| 1093 Views | ||
|
Page:
1
|
Go to Top |


