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   5082 Views

Avatar
UncleCheese

Forum Moderator, 4096 Posts

15 July 2009 at 12:25pm

I'm not really clear on what you're trying to do. Please provide some concrete examples if you can. Thanks.

Avatar
alexanm

Community Member, 38 Posts

15 July 2009 at 4:24pm

Hello UncleCheese,

ok I'll give you an example on what I am trying:

I have written a descendant of your CalendarDateTime (namely LineDanceDateTime) which has got a new field: Category. So each event and also each Announcement can get such a category. The categories are:

Training, Workshop, Course, ClubEvent, CountryEvent and so on.

Lets say I have made the following events and announcments:

* Training (event): Every two weeks from 19:00-21:00 between 1. July and 30. September
* ClubEvent (Event): Bowling on 28. May from 14: to 20:00
* ClubEvent (Announcement): Barbecue on 18. May from 19:00 to 00:00
* Workshop (Announcement): Workshop on 4. September from 18:30 to 20:00

Now I would like to have a widget which shows the next date for each of these event categories:

Upcoming events
============

20. July 2009, 19:00 - 21:00
Training

18. May 2009, 19:00 - 00:00
Barbecue

04. September 2009, 18:30 - 20:00
Workshop

How would I get this information in a fast and effective way? Especially the recurring events?

Hope that I could clarify the situation a bit...
Markus Alexander

Avatar
UncleCheese

Forum Moderator, 4096 Posts

16 July 2009 at 3:47am

Before I get to that, let me update you on some of the previous requests you've made:

The Nice() function is used in the CalendarDateTime._Times() function --> As I do not see any place where I can set the format of the time it prints the time in 12 hour format. I have managed to override this function in my descendant of CalendarDateTime and use the function Nice24().

==> Time format now defaults to 24-hour. You can set in your _config.php:
CalendarDateTime::set_time_format('24');
CalendarDateTime::set_time_format('12');

The $month_map array is used when building the filter dropdown as described above. I could not manage to change this behaviour in my code, so I had to change the original files again.

==> This is fixed. It now returns a translated date string using strftime();

One more point is that the ${sMonthShort}, ${eMonthShort}, ${sMonthFull} and ${eMonthFull} in the calendar headers are in english as well, even when I have set the language of the calendar to german. Is there a way to change this behaviour.

==> This is handled by the "OneDayHeader" "MonthHeader" and "YearHeader" tags in the lang file:

// "Headers" control the display when a date range is given to the calendar through the URL.
$lang['en_US']['Calendar']['OneDayHeader'] =
   '%{sMonFull} %{sDayNumShort}%{sDaySuffix}, %{sYearFull}';

$lang['en_US']['Calendar']['MonthHeader'] =
   '%{sMonFull}, %{sYearFull}';

$lang['en_US']['Calendar']['YearHeader'] =
   '%{sYearFull}';   

I also have managed to change the english date title in the datepicker by copying the jquery files into mysite and use these ones in my templates. Any better workaround for this?

==> You can now translate the calendar widget by specifying which locale file it should use in event_calendar/javascript/locale

$lang['en_US']['CalendarWidget']['LOCALEFILE'] = 'date_en.js';

I thought that php will handle all the date stuff (correct language and formats) by itself, when you set the correct locale.

==> Sort of. You have to use strftime() in lieu of date();

In the calendar widget you can click on the month and year header, but the cursor is an IBeam.

==> Haven't noticed this. It is in an anchor tag, so I can't imagine why it would be an I-Beam. Maybe you're on an old version?

And the really last thing: Could you also add localizations for the filter captions (start and end), please?

==> Done!

CalendarFilterFieldSet.START
CalendarFilterFieldSet.END

Avatar
UncleCheese

Forum Moderator, 4096 Posts

16 July 2009 at 5:50am

Edited: 16/07/2009 5:51am

For your other problem, here's a solution:

function NextTrainingEvent()
{
return DataObject::get_one("Calendar")->UpcomingEvents(1,"Category = 'Training'");
}

function NextBarbecueEvent()
{
return DataObject::get_one("Calendar")->UpcomingEvents(1,"Category = 'Barbecue'");
}

function NextWorkshopEvent()
{
return DataObject::get_one("Calendar")->UpcomingEvents(1,"Category = 'Workshop'");
}

To save on queries, you could cache the Calendar object.

Avatar
alexanm

Community Member, 38 Posts

16 July 2009 at 7:58pm

Hello UncleCheese,

thanks for your reply. I will have a look at the new version on weekend.

I have also tried your solution for my second question:

function NextTrainingEvent()
{
return DataObject::get_one("Calendar")->UpcomingEvents(1,"Category = 'Training'");
}

This won't work as, the Category is define on the DateTime class not the event class. When I use this condition for the announcement filter it will give me a result, but it doesn't matter waht category I put in, I always get the same result...

Any other ideas?

Thanks
Markus

Avatar
UncleCheese

Forum Moderator, 4096 Posts

17 July 2009 at 1:08am

The filter clause should be table agnostic. It's applied to a query that joins event objects on to datetime objects, so as long as you're specific about the column you want filtered, e.g., no ambiguity like "ID = 3" you should be fine. Try adding the name of your datetime as a prefix to be more specific.

UpcomingEvents(1, "MyDateTime.Category = 'Foo'");

Avatar
alexanm

Community Member, 38 Posts

17 July 2009 at 1:15am

Well the problem is, that my custom DateTime class is not in the query....

[User Error] Couldn't run query: SELECT `SiteTree_Live`.*, `CalendarEvent_Live`.*, `SiteTree_Live`.ID, if(`SiteTree_Live`.ClassName,`SiteTree_Live`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree_Live` LEFT JOIN `CalendarEvent_Live` ON `CalendarEvent_Live`.ID = `SiteTree_Live`.ID LEFT JOIN CalendarDateTime ON CalendarDateTime.EventID = CalendarEvent_Live.ID WHERE (Recursion = 1 AND ParentID = 10 AND Category = 'Training') AND (`SiteTree_Live`.ClassName IN ('LineDanceEvent')) AND (`SiteTree_Live`.`Locale` = 'de_DE') AND (`SiteTree_Live`.`Locale` = 'de_DE') GROUP BY `SiteTree_Live`.ID ORDER BY CalendarDateTime.StartDate ASC Unknown column 'Category' in 'where clause'

Did I miss anything somewhere else?

Thanks
Markus

Avatar
UncleCheese

Forum Moderator, 4096 Posts

17 July 2009 at 1:32am

I thought you said you had subclassed these objects? There is no category field on the CalendarDateTime class. What is the name of the class you're using?