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

[sitetree_link id=1773] links in the RSS Feed


Reply

4 Posts   1282 Views

Avatar
Tama

31 March 2011 at 9:59am Community Member, 130 Posts

Morning

If a user subscribes to our RSS Feed (www.tasman.govt.nz/home/rss) the links in the RSS items appear as "http://www.tasman.govt.nz/[sitetree_link id=1773]" which means if the user clicks through on an in-item link they get a 404 page with the following URL: http://www.tasman.govt.nz/%5bsitetree_link%20id=1773%5d

How easy is it to achieve either of the following:

1.) Use a URL rewrite to redirect the sitetree_link to the correct page. Is there a native PURL format in Silverstripe? i.e. www.tasman.govt.nz/page/1773

2.) Rewrite the links during the RSS generation so they contain the current URL.

Cheers
Tama

Avatar
Willr

31 March 2011 at 6:54pm Forum Moderator, 5511 Posts

Hi Tama, See my post (http://silverstripe.org/general-questions/show/16384#post301296) for an explanation.

Avatar
Tama

1 April 2011 at 4:54pm Community Member, 130 Posts

Thanks Will, much appreciated.

As I side note I noticed your Silverstripe tries to parse the sitetree_link in my thread title in the HTML page <title> and breadcrumb (see attached screenshot)

Attached Files
Avatar
inCharge

14 July 2011 at 8:24pm Community Member, 102 Posts

Thanks Will, and thanks Tama for putting your finger on the problem.

Some woking code using Will's tip...

class ArticlePage extends Page {

   .

   .

   .

   function RssContent() {

      // Pass the Content field to the RSS feed, so shortcodes are processed

      return DBField::create('HTMLText', $this->Content);

   }

}

class ArticleHolder_Controller extends Page_Controller {

   function rss() {

    $rss = new RSSFeed(

       $this->Children()

       , $this->Link()

       , 'Latest news'

       , null

       , 'Title'

       , 'RssContent' // Tell the RSS feed which field to use to retrieve Content
      );

    $rss->outputToBrowser();

   }

   public function init() {

      RSSFeed::linkToFeed($this->Link() . "rss");

      return parent::init();

   }

}