Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Preview: Event Calendar Module

Discuss all other Modules here.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
Go to End
Author Topic: 40779 Views
  • banal
    Avatar
    Community Member
    901 Posts

    Re: Preview: Event Calendar Module Link to this post

    Hi UncleCheese
    Yes, either the <% require %> tag or just plain html includes. The require tag is possibly the better choice since it prevents duplicates.
    From studying the SSViewer class, I was able to figure out how this tag works:
    The first part is the keyword "require", followed by the method to call with arguments in braces.

    <% require css(path/to/my/file.css) %>


    Will call Requirements::css('path/to/my/file.css');
    Same goes for JavaScript, eg.

    <% require javascript(path/to/my/file.js) %>

    HTH

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Preview: Event Calendar Module Link to this post

    Hello, it's me again.

    I hacked the Calendar classes to output european-formatted dates. Not in a generic/reusable way though... that would require quite an amount of refactoring i guess.
    I set the locale using setlocale. Then I changed the methods of the Calendar class to use strftime instead of date. Example:

    case "day":
    return strftime('%d. %B %Y', $this->start_date->get());
    // instead of: return $this->start_date->format('F jS, Y');

    Just in case somebody tries the same thing...

    @UncleCheese: Have you thought about highlighting the dates where an event occurs in the calendar widget? I guess it should be feasible using the renderCalendarCallback setting of the CalendarWidget: http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/renderCalendarBankHolidays.html
    Ranges could be a problem though.. what do you think?

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Preview: Event Calendar Module Link to this post

    Hello UncleCheese,

    your calendar is great, thank you. I´m looking forward to the improvements, especially european date format.

    I love Silverstripe! It´s amazing what featureful sites can be build with a little knowlege of PHP and OOP.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: Event Calendar Module Link to this post

    @ banal - Glad you got it working. The part I'm struggling with is giving the user the ability to choose which format characters to plug into the date() function. For instance, some users may want "October" in lieu of "Oct." That only really matters in the getDateString() method that returns a magically rendered date span in its template function $_Dates. So I may just make that US format only for now, or limit the options for European. Ultimately, date display should be left to the template, so I don't mind empowering users to handle it as they wish using $StartDate.Format() and $EndDate.Format().

    Hopefully I'll get some time into it today.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Preview: Event Calendar Module Link to this post

    Hi UncleCheese

    Yes, putting this stuff into templates makes sense. I'd keep the "magic" stuff to a minimum and rather provide start- and end-dates or other information the user can then mix freely in his templates. If he wishes another formatting, overriding the base class and adding custom controls (public methods) should do the trick.
    Be sure to use strftime instead of date, since it is "locale-aware".

    I'll check out if I can make the highlighting work..

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: Event Calendar Module Link to this post

    Thanks for the strftime idea. Did not know date() wasn't locale aware.

    Making the calendar widget event-aware is a whole other project. Because it's javascript-based, right now we can only get the events for the current month. We could frontload it with several months of future events and add a lot of overhead, but ideally what you want is an AJAX based calendar that will populate itself with each turn of the page.

    Anxious to see what you come up with, though. It would be a great feature.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Preview: Event Calendar Module Link to this post

    I did some tests and I guess the "renderCallback" option of the datePicker widget could work for the event highlighting. As you said, this would require prefetching all of the event dates and write them to javascript... I'm not really sure if I correctly understand your class and DB dependencies. Would it be possible to fetch all event dates (or ranges) with a simple db query? I guess the problem will be caused by the recurring/interval types of events, right?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: Event Calendar Module Link to this post

    That's precisely the problem. All of the recurring events are injected on the PHP side, not in MySQL. I tried very hard to come up with a query that would work, but to no avail, it has to be done in the controller. That's why everything has to get routed through the Events() function.

    One quick way to do it would be $this->UpcomingEvents(999). But that wouldn't get anything before today.

    I'll have to revisit that Events function. It's pretty flexible. Should be able to throw it a start and end date (sfDate objects) and have it do its thing.

    40779 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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.