Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Can I use the RSS Widget for a regular SS page and not in blog?


Go to End


7 Posts   3080 Views

Avatar
jaytay

Community Member, 15 Posts

31 October 2008 at 2:48pm

Hey folks,
wondering if there was a simple way to parse RSS feeds on my homepage for an external blog. I need to use an external websites RSS for the news section of my SS site. For example it would list the last 5 posts from the blog. I looked at the RSS Widget but it looked like that was strictly for the blog (maybe)? Can this widget be used for standard ss pages? If so how? Please note that I am a newb in the world of SS.
Thanks!

Avatar
Willr

Forum Moderator, 5523 Posts

31 October 2008 at 3:45pm

yep you can. Well you dont need to use the widget, you could just copy how the widget does it in your own homepage.

function CustomRSSFeed() {
    $feed = new SimplePie(URL OF THE RSS FEED);
    $feed->feed->init();
    $output = new DataObjectSet(); 
    if($items = $feed->feed->get_items(0, 10)) {
	foreach($items as $item) {
		$output->push(new ArrayData(array(
			"Title" => $item->get_title(),
			"Link" => $item->get_link()
		)));
	}
   }
	return $output;
}

I think might work in 2.2.2. If your template you would do <% control CustomRSSFeed %>$Title<% end_control %>

Avatar
jaytay

Community Member, 15 Posts

2 November 2008 at 7:48am

Wasn't working so I looked under the hood and see that I am running 2.2.1. Now debating whether to upgrade or to see if there is an easy work-around for this version.. suggestions?
thanks for all your help!

Avatar
jaytay

Community Member, 15 Posts

4 November 2008 at 12:59pm

uh oh. Error message. not sure if its because i tinkered with your code or anther reason but on rebuild of the db the i get an error towards the bottom of the build list. help!
<code>Group_Unsecure
Member
Member_UnsubscribeRecord
Permission
Widget
WidgetArea
ERROR:
Error

The website server has not been able to respond to your request</code>

Avatar
Willr

Forum Moderator, 5523 Posts

4 November 2008 at 1:04pm

ERROR: 
Error

The website server has not been able to respond to your request

is the standard error page. Turn on more useful error messaging by putting the site in dev mode. Add this to your mysite/_config.php file - Director::set_environment_type("dev"); This will output a proper error.

Avatar
jaytay

Community Member, 15 Posts

4 November 2008 at 1:20pm

hmmmmmm. Don't think it was the config file but the server is completely not responding now. I have a feeling i mucked up the db. Is there such a thing as the constant loading white screen of death?

Avatar
jaytay

Community Member, 15 Posts

5 November 2008 at 1:10am

I resolved all other problems and can get bakc to my RSS problem now...
I think my last question to you was whether your code would work in 2.2.1? I did a search and SimplePie is definately built into the core in some respect. Not sure if it's just for the blog widget though.