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.

All other Modules /

Discuss all other Modules here.

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

EventCalendar and announcements


Reply


40 Posts   5066 Views

Avatar
alexanm

Community Member, 38 Posts

17 July 2009 at 1:49am

Hello,

yes I have written descendants for the classes:

Calendar -> LineDanceEventHolder
CalendarEvent -> LineDanceEvent
CalendarDateTime -> LineDanceDateTime (this has the category field)

Thanks
Markus

Avatar
UncleCheese

Forum Moderator, 4096 Posts

17 July 2009 at 1:56am

Doh!

You should be doing DataObject::get_one("MyCalendarClass")->UpcomingEvents(....); so that it's aware of the custom classes.

Avatar
alexanm

Community Member, 38 Posts

17 July 2009 at 3:55am

Hello,

ok I have tried that to, but it does not change anything in the generated sql command.

Markus

Avatar
alexanm

Community Member, 38 Posts

20 July 2009 at 10:00pm

Hello UncleCheese,

perhaps a few more words for clarifying the above Situation:

I have created Descendants of all the Calendar classes, as written in aprevious Post. The only thing I did not do is, to recreate the associations between the classes. I have only set the class names of the related class in my descendants. Perhaps this is not enaough, for the DataObject.get to work...

And the second thing is, that the filtering for DateTime fields does not work (In my case Category of my descendant). We have spoken about this a few posts before...

As always:
Many thanks for your fast and professional help
Markus Alexander

Avatar
alexanm

Community Member, 38 Posts

3 August 2009 at 2:54am

Hello UncleCheese,

as I did not get any answer on my last few posts, I am trying to reactivate this topic once more.
I have just downloaded and installed the r60 version of the event calendar, but a few things ar not workling with this version.

First of all, I post my derived claendar classes:

<?php

class LineDanceEventHolder extends Calendar {

   static $default_child = 'LineDanceEvent';
   
   protected $event_class = 'LineDanceEvent';
   protected $event_datetime_class = 'LineDanceDateTime';

   public function getFilterFields() {
    $fields = parent::getFilterFields(); // returns a CalendarFilterFieldSet
    $fields->addFilterField(new DropdownField('LineDanceDateTime_Category', 'Kategorie', singleton('LineDanceDateTime')->dbObject('Category')->enumValues()));
    return $fields;
   }   

   public function LineDanceCalendarWidget() {
      return new LineDanceCalendarWidget($this, $this->start_date, $this->end_date, ($this->view == "default"));
   }

}

class LineDanceEventHolder_Controller extends Calendar_Controller {

}

?>

<?php

class LineDanceEvent extends CalendarEvent {

   protected $datetime_class = 'LineDanceDateTime';
      
}

class LineDanceEvent_Controller extends CalendarEvent_Controller {

   public function init() {
      parent::init();
      
      // ----- include google api
      global $GMaps_API_Key;
Requirements::insertHeadTags("<script src='http://www.google.com/jsapi?key=".$GMaps_API_Key."' type='text/javascript'></script>");
   }

   public function LineDanceCalendarWidget() {
      return $this->Widget('LineDanceCalendarWidget');
   }
   
}

?>

<?php

class LineDanceDateTime extends CalendarDateTime {

   static $db = array (
      'Category' => 'Enum(\'Training, Workshop, Auftritt, Kurs, Country Event, Club Event\', \'Country Event\')',
      'Music' => 'Varchar(64)',
      'ExternalLink' => 'Varchar(256)',
      'Address' => 'Varchar(256)',
      'PlannedVisit' => 'Boolean'
   );

   public function extendTable() {
      $fields = array(
         new DropdownField('Category', 'Kategorie', singleton('LineDanceDateTime')->dbObject('Category')->enumValues()),
         new TextField('Address', 'Adresse'),
         new TextField('ExternalLink', 'Externer Link'),
         new TextField('Music', 'Musik'),
         new CheckboxField('PlannedVisit', 'Geplanter Besuch'),
      );
      
      $this->addPopupFields($fields);
   }
   
   
   public function extendAnnouncement() {
      $fields = array(
         new DropdownField('Category', 'Kategorie', singleton('LineDanceDateTime')->dbObject('Category')->enumValues()),
         new TextField('Address', 'Adresse'),
         new TextField('ExternalLink', 'Externer Link'),
         new TextField('Music', 'Musik'),
         new CheckboxField('PlannedVisit', 'Geplanter Besuch'),
         new TextareaField('Content'),
      );
      
      $this->addAnnouncementFields($fields);
   }
   
   public function _Times() {
      $ret = $this->obj('StartTime')->Nice24();
      $ret .= $this->EndTime ? " &mdash; " . $this->obj('EndTime')->Nice24() : "";
      return $ret;
   }
   
}

?>

With this classes I have the following problems:

* In LineDanceEventHolder.getFilterFields I am adding a new filter criteria from my DateTime descendant class. Using this filter ends in an sql error because the table LineDanceDateTime is somehow treated like a "SiteTree" Descendant and so the LineDanceDateTime_Live is joined. This table does not exist.

* When I add the filter from above, it does not look like the rest of the filter fields. Especially the line between the caption and the input field is missing. Any ideas how I can achieve the same display behaviour?

* I have written a small widget which shows the next calendar entry. I am using the Category field of my LineDanceDateTime descendant as a filter criteria. The code for selecting the next event looks like this:

   function NextAnnouncement($category) {
      $result = DataObject::get_one("LineDanceEventHolder")->UpcomingEvents(1, "Category = '$category'");
      return $result;
   }

This code won't work because my descendant class is not part of the query. The doc says that the second parameter of the UpcomingEvents method is the filter for the event, and the third is for the datetime. When I use this filter for the datetime parameter, there is no error, but the filter is not applied too...

I think thats it by the moment. Can you help me to fix the above mentioned issues?

TIA
Markus Alexander

Avatar
UncleCheese

Forum Moderator, 4096 Posts

3 August 2009 at 12:23pm

1) Try just "Category" (without the underscore syntax) for your filter field. I believe by default it looks on the DateTime class, but if you use the underscore relation it looks on the event class. It probably wasn't built as well as it could have been. :(

2) Not sure. Just play around with your stylesheet.

3) The module is picky about how subclasses are implemented. If you're running UpcomingEvents() against your Calendar subclass object, it should include that in the query. I'm guessing you don't have one of the relations set up properly. As I recall, the correct set up is:

CalendarSubClass
-- has_many EventSubClass, DateTimeSubClass

EventSubClass
-- has_one CalendarSubclass
-- has_many DateTimeSubClass

DateTimeSubClass
-- has_one CalendarSubClass, EventSubClass

But check the docs on "extending the event calendar" for more accurate info. Again, it probably isn't built as well as it could be.

Avatar
alexanm

Community Member, 38 Posts

3 August 2009 at 7:40pm

Hello,

3) So do I need to create the relations on my descendants too? I thought, it would not be necessary, as this is already handled by the parent classes...

For the rest: I will give it a try...

Thanks
Markus

Avatar
alexanm

Community Member, 38 Posts

3 August 2009 at 7:44pm

Hello again,

ok I tried your suggestion in number 1, but then it tries to look for a column 'Category_Live' which is even worse, than the previous result...

Markus