7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » extending event_calendar and rss
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 997 Views |
-
extending event_calendar and rss

23 January 2010 at 2:47pm Last edited: 23 January 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)
-
Re: extending event_calendar and rss

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...
-
Re: extending event_calendar and rss

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
-
Re: extending event_calendar and rss

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().
-
Re: extending event_calendar and rss

26 January 2010 at 5:28am Last edited: 26 January 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 rssclass 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
| 997 Views | ||
|
Page:
1
|
Go to Top |

