Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Event Calendar Widget

Discuss SilverStripe Widgets.

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

Page: 1 2
Go to End
Author Topic: 8881 Views
  • OriginalThing
    Avatar
    Community Member
    3 Posts

    Re: Event Calendar Widget Link to this post

    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

  • OriginalThing
    Avatar
    Community Member
    3 Posts

    Re: Event Calendar Widget Link to this post

    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
  • VanceK
    Avatar
    Community Member
    17 Posts

    Re: Event Calendar Widget Link to this post

    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

  • VanceK
    Avatar
    Community Member
    17 Posts

    Re: Event Calendar Widget Link to this post

    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

  • OriginalThing
    Avatar
    Community Member
    3 Posts

    Re: Event Calendar Widget Link to this post

    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.

    8881 Views
Page: 1 2
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.