CGCalendar 1.14+ new all day flag template changes

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

CGCalendar 1.14+ new all day flag template changes

Post by paulbaker »

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:

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"}...
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:

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"}...
This idea needs to be applied to most templates so they all display all-day events properly.

Hope this saves some people some time. :D
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: CGCalendar 1.14+ new all day flag template changes

Post by calguy1000 »

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.
The upgrade routine is supposed to set that flag.... unless either an error got introduced into the query OR there is some other database issue on your end.

Edit: I tested it again. worked fine here.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGCalendar 1.14+ new all day flag template changes

Post by paulbaker »

Thanks for the reply Calguy, how odd, I definitely needed the above code. The site in question was launched with CGCalendar in late 2012 and has been updated periodically since.

Here's the current system info.

Anyway, good to hear that in theory this is not needed. I have more sites with CGCalendar to update, I will keep a close eye when I do that.

----------------------------------------------
Cms Version: 1.11.10
Installed Modules:
CMSMailer: 5.2.2
CMSPrinting: 1.0.5
FileManager: 1.4.4
MenuManager: 1.8.6
MicroTiny: 1.2.6
ModuleManager: 1.5.5
News: 2.14.2
Search: 1.7.11
ThemeManager: 1.1.8
TinyMCE: 2.9.12
CGExtensions: 1.39
CGCalendar: 1.14.3
CGSimpleSmarty: 1.7.3
CGGoogleMaps: 2.4.7
Statistics: 1.1.3
SiteMapMadeSimple: 1.2.8
Notifications: 1.1
Archiver: 0.2.6
ListIt2: 1.4.1
ListIt2Governors: 1.4.1
GBFilePicker: 1.3.3

Config Information:
php_memory_limit:
process_whole_template:
max_upload_size: 32000000
url_rewriting: mod_rewrite
page_extension:
query_var: page
image_manipulation_prog: GD
auto_alias_content: true
locale:
default_encoding: utf-8
admin_encoding: utf-8
set_names: true

Php Information:
phpversion: 5.4.21
md5_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_STRICT: 0
E_DEPRECATED: 0
memory_limit: 128M
max_execution_time: 120
output_buffering: 4096
safe_mode: Off (False)
file_uploads: On (True)
post_max_size: 8M
upload_max_filesize: 32M
session_save_path: /tmp (1777)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)

Server Information:
Server Api: cgi-fcgi
Server Db Type: MySQL (mysqli)
Server Db Version: 5.1.73
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable
Server Time Diff: No filesystem time difference found

----------------------------------------------
StMarys
Locked

Return to “Tips and Tricks”