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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Truncate RssFeed


Go to End


2 Posts   1207 Views

Avatar
Double-A-Ron

Community Member, 607 Posts

5 April 2011 at 3:52pm

I have the following functions in my HomePage controller displaying XML to /home/rss:


        // ----------------------------------------------------------------------------
	// GET LATEST NEWS                                                             
	// ----------------------------------------------------------------------------
	function LatestNews() 
	{
		$news = DataObject::get_one("ArticleHolder");
		return ($news) ? DataObject::get("ArticlePage", "", "Date DESC", "", 3) : false;
	}
	
	
	// ----------------------------------------------------------------------------
	// RSS NEWS FEED                                                               
	// ----------------------------------------------------------------------------
	function rss() 
	{
		$rss = new RSSFeed(self::LatestNews(), $this->Link(), parent::GetConfig()->SiteName." - Latest News");
		$rss->outputToBrowser();
	}

Works fine, although it pulls the entire article out in HTML format, image included (which is a separate dataobject on the pagetype rather than one inserted into the content.

Is there a way I can output on the content portion of the object returned from LatestNews?

Aaron

Avatar
Double-A-Ron

Community Member, 607 Posts

6 April 2011 at 8:33am

My mistake, the image and caption actually are in the main content of the page type.

So all I am looking to do here is to output the Content records with HTML stripped just the same as using $Content.LimitWordCount(50) in a template.

I can't see any options for this in the Doc. I have also had a play around with the RSSFeed class in sapphire/api. Will we really have to hand code the XML output to acheive this?