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

[sitetree_link id=1773] links in the RSS Feed


Go to End
Reply


4 Posts   1516 Views

Avatar
Tama

Community Member, 133 Posts

31 March 2011 at 9:59am

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

Forum Moderator, 5521 Posts

31 March 2011 at 6:54pm

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

Avatar
Tama

Community Member, 133 Posts

1 April 2011 at 4:54pm

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

Community Member, 102 Posts

14 July 2011 at 8:24pm

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();

	}



}