Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » extending event_calendar and rss

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1132 Views
  • Victor
    Avatar
    Community Member
    128 Posts

    extending event_calendar and rss Link to this post

    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)

  • UncleCheese
    Avatar
    4085 Posts

    Re: extending event_calendar and rss Link to this post

    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...

  • Victor
    Avatar
    Community Member
    128 Posts

    Re: extending event_calendar and rss Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: extending event_calendar and rss Link to this post

    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().

  • Victor
    Avatar
    Community Member
    128 Posts

    Re: extending event_calendar and rss Link to this post

    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

    1132 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.