Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

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

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

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

Page: 1
Go to End
Author Topic: 2150 Views
  • jaytay
    Avatar
    Community Member
    15 Posts

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

    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!

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: Can I use the RSS Widget for a regular SS page and not in blog? Link to this post

    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 %>

  • jaytay
    Avatar
    Community Member
    15 Posts

    Re: Can I use the RSS Widget for a regular SS page and not in blog? Link to this post

    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!

  • jaytay
    Avatar
    Community Member
    15 Posts

    Re: Can I use the RSS Widget for a regular SS page and not in blog? Link to this post

    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>

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: Can I use the RSS Widget for a regular SS page and not in blog? Link to this post

    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.

  • jaytay
    Avatar
    Community Member
    15 Posts

    Re: Can I use the RSS Widget for a regular SS page and not in blog? Link to this post

    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?

  • jaytay
    Avatar
    Community Member
    15 Posts

    Re: Can I use the RSS Widget for a regular SS page and not in blog? Link to this post

    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.

    2150 Views
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.