CGCalendar 1.14+ new all day flag template changes
Posted: Wed Jul 09, 2014 1:00 am
I had to debug a site which I had recently updated and which was displaying strange calendar data in the front end. I noticed that CGCalendar 1.14 shows "Adds all day event flag" in its changelog.
The old way of storing these events was the backend would set the start time as 00:00 and the finish time as 23:59. Then, we had something like this in the templates which spotted an all day event and changed display accordingly:
Now, with the "all day event flag" that was added in 1.14 the backend appears to leave the times set to whatever the default is and so when admins add new all-day events, this template idea doesn't work any more. Because of course, the old events added before the update are still in "00:00/23:59" format whereas new all day events entered will have the new all day flag set.
So, how to detect the flag?
After a bit of digging in the new default templates, I saw the code you need to check for this new flag. And so here is the sort of code change you need to detect the original "00:00/23:59" all day events and the new all day events with the all day flag set:
This idea needs to be applied to most templates so they all display all-day events properly.
Hope this saves some people some time.
The old way of storing these events was the backend would set the start time as 00:00 and the finish time as 23:59. Then, we had something like this in the templates which spotted an all day event and changed display accordingly:
Code: Select all
{if $event.event_date_start|date_format:"%l:%M %P" == "12:00 am" && $event.event_date_end|date_format:"%l:%M %P" == "11:59 pm"}...
So, how to detect the flag?
After a bit of digging in the new default templates, I saw the code you need to check for this new flag. And so here is the sort of code change you need to detect the original "00:00/23:59" all day events and the new all day events with the all day flag set:
Code: Select all
{if ($event.event_date_start|date_format:"%l:%M %P" == "12:00 am" && $event.event_date_end|date_format:"%l:%M %P" == "11:59 pm") OR $event.event_all_day == "1"}...
Hope this saves some people some time.
