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.

Customising the CMS

How do you extend the RSS Feeds?


Reply

651 Views

Avatar
otherjohn

7 July 2011 at 7:39am Community Member, 125 Posts

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;
   }