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.

Customising the CMS /

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

How do you extend the RSS Feeds?


Go to End


1399 Views

Avatar
otherjohn

Community Member, 125 Posts

7 July 2011 at 7:39am

Hi all,
I am trying to extend my rss feeds for the events calendar to include some fields for additional Schemas (like GeoRSS) but can't seem to get it to pass those fields ($longitude and $latitude) to the rssfeed.ss file.

I have the following code in my calendar.php file, but my question is how do I grab a field like $longitude from the $events DataObjectSet.
I have tried $this->longitude & $events->longitude with no luck. If I do a print_r of the $events I see that it is set. Can someone help me?

public function atom()
	{
		$events = $this->getModel()->UpcomingEvents(null,$this->DefaultEventDisplay);
		foreach($events as $event) {
			$event->Title = strip_tags($event->_Dates()) . " : " . $event->EventTitle();
			$event->Description = $event->EventContent();
			
			
		}
		
		$rss = new EventFeed(
							$events, 
							$this->Link(), 
							sprintf(_t("Calendar.UPCOMINGEVENTSFOR","Upcoming Events for %s"),$this->Title), 
							"",
							"Title", 
							"Description"
							);

		if(is_int($rss->lastModified)) {
			HTTP::register_modification_timestamp($rss->lastModified);
			header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $rss->lastModified) . ' GMT');
		}
		if(!empty($rss->etag)) {
			HTTP::register_etag($rss->etag);
		}
		$xml = str_replace(' ', ' ', $rss->renderWith('EventFeed'));
		$xml = preg_replace('/<!--(.|\s)*?-->/', '', $xml);
		$xml = trim($xml);
		//HTTP::add_cache_headers();
		header("Content-type: text/xml");
		echo $xml;
	}