Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Posting RSS Feed on ArticleHolder.ss

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1104 Views
  • Happysadhu
    Avatar
    Community Member
    33 Posts

    Posting RSS Feed on ArticleHolder.ss Link to this post

    Hello,
    I would like to post the following pubmed RSS feed on my articleholder page:
    http://eutils.ncbi.nlm.nih.gov/entrez/eutils/erss.cgi?rss_guid=1JAk5IMbg5brNNHlJdI8W1KPW9SEh2vqRx6_PmPUwADwffFU05

    I've looked at a number of posts on the subject and I'm still confused as there are a number of suggested approaches (some likely outdated). What is considered to be the easiest, most up-to-date way to show a rss feed on any given page (SS version 2.3.2+)?

    I came across this post: http://www.silverstripe.org/archive/show/218454#post218454 where Willr suggested the following code (which I added to my ArticleHolder.php file):

    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;
    }

    Using <% control CustomRSSFeed %>$Title<% end_control %> in ArticleHolder.ss.

    However, I get the following error: Fatal error: Class 'SimplePie' not found in /Applications/XAMPP/xamppfiles/htdocs/holybasil/mysite/code/ArticleHolder.php on line 27. I put my url in quotes for $feed, without which there was an additional error.

    I tried the restfulservice approach as suggested at the bottom of this link.
    http://doc.silverstripe.com/doku.php?id=restfulservice#how_to_use_restfulservice_to_easily_embed_an_rss_feed

    But just as "Superautomatic" commented in his post at http://silverstripe.org/archive/show/89336#post89336, I can only get the example RSS feed to work not my own (see above for the RSS address). I suspect that it is RSS 1.0 versus RSS 2.0 issue (my RSS address being 2.0). Jam13 offered some code at the bottom of the Superautomatic posting. However, I have no idea how to implement it in a template. He doesn't give an example.

    I would appreciate any help,
    Sam

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Posting RSS Feed on ArticleHolder.ss Link to this post

    I just ran into the same issue. That code worked in 2.2.x, but is now broken in 2.3.x.

    It's borrowed from the Blog Module (or somewhat similar). Blog > Code > RSSWidget.php

    Download the newest version of the Blog Module and grab the updated code and paste into your page. I did so, and it's working fine on my site.

    1104 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.