Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How do you extend the RSS Feeds?

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

Page: 1
Go to End
Author Topic: 636 Views
  • otherjohn
    Avatar
    Community Member
    125 Posts

    How do you extend the RSS Feeds? Link to this post

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

    636 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.