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.

Widgets /

Discuss SilverStripe Widgets.

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

Event Calendar Widget


Go to End
Reply


13 Posts   9100 Views

Avatar
OriginalThing

Community Member, 3 Posts

2 November 2010 at 8:48pm

Edited: 02/11/2010 8:54pm

Hey guys,

I have been helping Lavan out with the issues when using this widget with SS 2.4.

Here are a list of all the changes made:

EventCalendarWidget.ss, line 1 : Change the class of the div to something other than "EventCalendarWidget". I suggest something like "Widget_EventCalendar"

EventCalendarWidget.js, line 3 : Change the jQuery selector to the same class as used in line 1 of EventCalendarWidget.ss

EventCalendarWidget.js, line 27 : Change from "location.href = this.options.calendar + dateText;" to "location.href = this.options.calendar + "view/" + dateText;"

(line numbers change heaps but should be fairly straight forward)
EventCalendarWidget.php : Change the class that EventCalendarWidget_Controller extends from Controller to Widget_Controller

EventCalendarWidget.php : Move (or copy) the Content method from the Model class (EventCalendarWidget) to the Controller class (EventCalendarWidget_Controller)

(this might be optional but should be done as best practice as a page should not have multiple jQuery libraries)
EventCalendarWidget.php : Change the line containing "Requirements::javascript('widget_EventCalendar/javascript/jquery-1.3.2.min.js');" to "Requirements::javascript('sapphire/thirdparty/jquery/jquery.js');"


Some of these Lavan already said to do but thought I would put them together in one place.

I've tested this with SS 2.4.2 and have attached the widget with all of the above changes made to it

Avatar
OriginalThing

Community Member, 3 Posts

3 December 2010 at 6:28pm

Hi everyone,

I have looked into this Event Calendar Widget some more and found these changes that need to be made:

EventCalendarWidget.js, line 114 : Change from "location.href = widget.options.calendar + widget.monthYear;" to "location.href = widget.options.calendar + "view/" + widget.monthYear;"

EventCalendarWidget.php, line 139 : Change "HTTPRequest" to "SS_HTTPRequest" due to renaming of some classes for the SilverStripe 2.4 release to reduce classname conflicts

EventCalendarWidget.php, line 149 : Change "HTTPResponse" to "SS_HTTPResponse" same reason as above

EventCalendarWidget.php, line 155 : Change "HTTPResponse" to "SS_HTTPResponse" same reason as above

EventCalendarWidget.php, line 231 : Change "HTTPResponse" to "SS_HTTPResponse" same reason as above

The first change fixes the behavior when clicking the month title on the widget. The rest of the changes fixes the Live mode so only dates that have an event are click-able.

I have also noticed some odd behavior where the widget shows Events that are in the draft site but are not published. I appears that this method in Calendar.php of the Event Calendar module is where the unpublished Events are being included:

   protected function getEventIds()
   {
      $ids = array();
      if($children = $this->Children()) {
         foreach($children as $child)
            $ids[] = $child->ID;

         return $ids;
      }
      else {
         return false;
      }
   }

My understanding is that "$this->Children()" should only return published pages but for some reason it is returning unpublished pages also. A solution I thought of is to add an if statement to check the isPublished value but I don't think that is right. Maybe someone else could try and find out what is happening here.

Attached Files
Avatar
VanceK

Community Member, 17 Posts

23 January 2011 at 7:01am

I'm having problems getting the widget working correctly. When I click on a day in the widget I get forwarded to the correct events for that day, but the widget displays December 1969 rather than the current date. Does anyone have a suggestion as to what I need to fix/change to make it work correctly?

Thanks all,
Vance

Avatar
VanceK

Community Member, 17 Posts

23 January 2011 at 8:05am

Edited: 23/01/2011 8:06am

After poking around in the code for awhile, I think it's working correctly now.

I changed line 29 in EventCalendarWidget.php from:

$dateText = join('-', array_pad(explode('-', $urlParams['Action']), 3, '01'));

to

$dateText = $urlParams['ID'];

-Vance

Avatar
OriginalThing

Community Member, 3 Posts

24 January 2011 at 11:53pm

I had noticed that happened when I was working with this widget but never got to the root of the problem. Haven't really touched it since my last post. But if I remember correctly this would happen when you had this widget on an actual Event Calendar type page. And when I was working with it this wasn't a requirement.

Congrats Vance on finding your own solution and sharing it here. I'm sure you will have helped someone out there.

Go to Top