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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

extending event_calendar and rss


Go to End


5 Posts   1524 Views

Avatar
Victor

Community Member, 128 Posts

23 January 2010 at 2:47pm

Edited: 23/01/2010 3:01pm

Following http://doc.silverstripe.org/doku.php?id=recipes:extending_the_event_calendar and Uncle Cheese advices we extended event_calendar to fit our needs as seminars module. So, each seminar is described by SeminarEvent [extends CalendarEvent] (say "Analysis Seminar") contains many talks, each talk described by SeminarDateTime [extends CalendarDateTime] contains datetime, location, title of the talk, .... SeminarEvent also has a general content describing purpose of seminar, organizers, blah blah. So far so good.

Our problem is that feed from seminar lists this general info rather than talks specifics. So question:

How extending event_calendar we can customize feed?

Thank you in advance. What we have and 99% happy with

http://www.math.toronto.edu/cms/events/

Victor

PS Sorry: occasionally posted in the wrong forum (albeit connected one)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 January 2010 at 3:23pm

Well, keep in mind that an RSS feed only gets a few fields -- Title, Description, Author, and Date. So if you're imagining that you can put more fields into it, that isn't going to work. You'll have to override the Title and Description fields to include the information you want.

I would overload the rss() function in your SeminarEvent_Controller class. In your subclass, you're going to want to handle these lines differently:

		foreach($events as $event) {
			$event->Title = strip_tags($event->_Dates()) . " : " . $event->EventTitle();
			$event->Description = $event->EventContent();
		}

You can make Title and Description anything you want...

Avatar
Victor

Community Member, 128 Posts

24 January 2010 at 12:07am

I am afraid I am making some mistake at it does not have any effect. So, let me ask in frames of Tutorial. Location first appears at

class WorkshopDateTime extends CalendarDateTime
{
  static $db = array (
   'Location' => 'Varchar(50)'
   );
 
   static $has_one = array (
    'Workshop' => 'Workshop'
   );
}

I want that rss feed include Location. If I understand your advice correctly I need to have

class Workshop_Controller extends CalendarEvent_Controller
 {
public function rss(){
foreach($events as $event) {         $event->Location = strip_tags($event->_Dates()) . " : " . $event->EventLocation();
         $event->Description = $event->EventContent();
      }
}

 }

Where is my mistake?

Thanks. Victor

Avatar
UncleCheese

Forum Moderator, 4102 Posts

24 January 2010 at 5:17am

By "overload" the function, I meant copy the whole thing out of the parent controller, and modify the lines you need to. Look at Calendar_Controller::rss().

Avatar
Victor

Community Member, 128 Posts

26 January 2010 at 5:28am

Edited: 26/01/2010 5:31am

I spent weekends trying to follow up but no success. So, in frame of Tutorial http://doc.silverstripe.org/doku.php?id=recipes:extending_the_event_calendar
until Even Further high level heading was repeated I copied from Calendar.php to Workshop_Holder.php function rss

class WorkshopHolder_Controller extends Calendar_Controller
{
public function rss()
        {
                $events = $this->getModel()->UpcomingEvents(null,$this->DefaultEventDisplay);
                foreach($events as $event) {
                        $event->Title = strip_tags($event->_Dates()) . " : " . $event->EventTitle();
                        $event->Description = $event->Speaker();
                }
                $rss = new RSSFeed($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('RSSFeed'));
                $xml = preg_replace('/<!--(.|\s)*?-->/', '', $xml);
                $xml = trim($xml);
                HTTP::add_cache_headers();
                header("Content-type: text/xml");
                echo $xml;
        }
}

and then tried to edit "red" lines to get Location coming in rss feed.
However all my attempts resulted either in "no effect" or "error" and thus I need a further hint.

Probably this should be a part of tutorial

Victor