Jump to:

23581 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » Simple Pie with Silverstripe

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: 1486 Views
  • MagicUK
    Avatar
    Community Member
    60 Posts

    Simple Pie with Silverstripe Link to this post

    Hey All. I've been using this tutorial to create an RSS aggregator on a site I'm working on.

    I have the following code above the doctype in one off my .ss tamplates pages:

    <?php

    //get the simplepie library
    require_once('assets/simplepie.inc');

    //grab the feed
    $feed = new SimplePie();

    $feed->set_feed_url(array(
       'http://feeds2.feedburner.com/CssTricks',
       'http://smashingmagazine.com',
    ));

    //enable caching
    $feed->enable_cache(true);

    //provide the caching folder
    $feed->set_cache_location('assets/cache');

    //set the amount of seconds you want to cache the feed
    $feed->set_cache_duration(1800);

    //init the process
    $feed->init();

    //let simplepie handle the content type (atom, RSS...)
    $feed->handle_content_type();

    ?>

    I have the simplepie.inc file in the assets folder and a cache directory with full writeable permissions, but unfortunately I'm getting the followng error:

    Parse error: syntax error, unexpected T_REQUIRE_ONCE in /tmp/silverstripe-cache-home-isslcom1-public_html/.cache.themes.blackcandy.templates.news.ss on line 9

    Would really appreciate any help.

  • MagicUK
    Avatar
    Community Member
    60 Posts

    Re: Simple Pie with Silverstripe Link to this post

    OK I've realised that the template files can't process the php from directly within the template file and I would need to call this php code from the php file for that specific page type.

    I have no idea how to do this though. Can someone point me in the right direction?

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Simple Pie with Silverstripe Link to this post

    Yes all PHP code should be in your PHP file!

    For a start make a new custom page type (as the tutorials explain) then you can make a custom function which returns a set of all your entries. See http://pastie.org/1479977 for a simple example.

    You can also use RestfulService for this sort of work - http://doc.silverstripe.org/sapphire/en/reference/restfulservice#other-uses

  • MagicUK
    Avatar
    Community Member
    60 Posts

    Re: Simple Pie with Silverstripe Link to this post

    Thanks Willr. I really appreciate your response.

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