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.

General Questions

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

RSS and silverstripe 3.1


Reply

3 Posts   489 Views

Avatar
nmshah

3 July 2013 at 4:45am (Last edited: 3 July 2013 5:01am), Community Member, 21 Posts

I have a code that was working in silverstripe 3.0 to show rss. But the same doesn't work on silverstripe 3.1

The code was put in mysite/code/page.php, which is as follows

<?php
class Page extends SiteTree {
   private static $db = array(
   );
   private static $has_one = array(
   );
}

class Page_Controller extends ContentController {
   private static $allowed_actions = array (
   );
   public function init() {
      RSSFeed::linkToFeed($this->Link() . "rss");
      parent::init();
   }
   public function rss() {
      $rss = new RSSFeed($this->LatestUpdates(), $this->Link(), "10 Most Recently Updated Pages", "Shows a list of the 10 most recently updated pages.");
      return $rss->outputToBrowser();
   }
   public function LatestUpdates() {
      return Page::get()->sort("LastEdited", "DESC")->limit(10);
   }
}

I was able to access the rss by using the following url

http://my-web-site-add/home/rss

The error that I get on silverstripe 3.1 when following the same process

Action 'rss' isn't allowed on class HomePage_Controller.

Do I need to change something to make this work in silverstripe 3.1

Avatar
Nobrainer Web

3 July 2013 at 7:44am Community Member, 135 Posts

I Think you just need to add rss to static allowed actions
private static $allowed_actions = array (
'rss'
);

Avatar
nmshah

4 July 2013 at 5:03pm Community Member, 21 Posts

Thank you. This works perfectly.