Page 1 of 1
[solved] CGCalendar All Day Time is showing as 1:15 AM?
Posted: Tue May 05, 2015 9:51 pm
by rbaby
I have some events that have a start time, some events with an end time, and some with no time at all and specified to All Day. However, the following template in the default which shows:
Code: Select all
{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'}</div>
{else}
{if $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'} {$lang.to} {$event.event_date_end|date_format:"%l:%M %p"}</div>
{else}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %H:%M'} {$lang.to} {$event.event_date_end|date_format:"%B %e, %Y %H:%M"}</div>
{/if}
My all-day events are appearing as 1:15 AM. How can I address this or add another if statement to not display time if it's set to All Day?
Thanks!
Re: CGCalendar All Day Time is showing as 1:15 AM?
Posted: Wed May 06, 2015 7:09 am
by velden
you could add some code in the template and print out the contents of each event variable. Then find the property that tells you it's an all day event and use that in the template.
Code: Select all
{foreach .... item=event}
...
<pre>{$event|print_r}</pre>
...
{/foreach}
Re: CGCalendar All Day Time is showing as 1:15 AM?
Posted: Wed May 06, 2015 7:49 am
by rbaby
Thanks velden! That print really helped...I was struggling a bit with the error but I realized that I was missing a closing {/if} statement. For anyone who is looking for a solution, this is what I ended up with:
Code: Select all
{if $event.event_all_day == 1}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y'}</div>
{else}
{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'}</div>
{else}
{if $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'} {$lang.to} {$event.event_date_end|date_format:"%l:%M %p"}</div>
{else}
<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %H:%M'} {$lang.to} {$event.event_date_end|date_format:"%B %e, %Y %H:%M"}</div>
{/if}
{/if}
{/if}
Re: [solved] CGCalendar All Day Time is showing as 1:15 AM?
Posted: Wed May 06, 2015 8:33 am
by velden
You could consider using {elseif ....} for readability and preventing the nesting. Further try to not repeat 'code' if not necessary (the div is the same for any condition, so put it outside the condition.
(untested:)
Code: Select all
<div class="calendar-date-from">
{if $event.event_all_day == 1}
{$event.event_date_start|date_format:'%B %e, %Y'}
{elseif $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'}
{elseif $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'} {$lang.to} {$event.event_date_end|date_format:"%l:%M %p"}
{else}
{$event.event_date_start|date_format:'%B %e, %Y %H:%M'} {$lang.to} {$event.event_date_end|date_format:"%B %e, %Y %H:%M"}
{/if}
</div>
Re: [solved] CGCalendar All Day Time is showing as 1:15 AM?
Posted: Wed May 06, 2015 8:50 am
by rbaby
Thank you, I will try it
