Page 1 of 1

CGCalendar Group Calendar List by Day

Posted: Wed Oct 07, 2015 8:13 pm
by cpansewicz
Hi,

I have CMS 1.11.4, and CGCalendar 1.10.4. I am trying to set-up an upcoming list template for an large event. I would like to group the events by day of the week. I am able to set-up the template so the day of the week shows up for each event, but how can I set-up the template so that, for instance, all the "Tuesday" events show up under a "Tuesday" header?

The template I started is below. Thank you for any assistance. I tried moving the Day of the Week to before the {foreach} statement with no luck, and wrapping the template in an additional {foreach} statement, but was unsuccessful there as well.

<div id="events">
{if isset($pastitems) && $pastitems == 0}

{foreach from=$events key=key item=event}

<!--Day of the week Code-->
{if $event.event_date_start|date_format:"%m" == $event.event_date_end|date_format:"%m" || $event.event_date_end == 0}
<h1>{$event.event_date_start|date_format:"%A"}</h1>
{/if}

<!--Event Code-->
<div>
<div>
<p>{$event.event_title}</p>
<p>{if $event.event_details !=""}{$event.event_details}{/if} </p>
.....etc
</div>
</div>
{/foreach}
{/if}
</div>

Re: CGCalendar Group Calendar List by Day

Posted: Wed Oct 07, 2015 8:57 pm
by velden
Think it would be a good idea to store the day of the week in a variable and every iteration check if it changed (not tested):

Code: Select all

{$previousDay=''}
{foreach from=$events key=key item=event}

<!--Day of the week Code-->
{assign var=currentDay value=$event.event_date_start|date_format:"%e"}
{if $previousDay != $currentDay}
  <h1>{$event.event_date_start|date_format:"%A"}</h1>
  {$previousDay=$currentDay}
{/if}

...

{/foreach}

SOLVED: CGCalendar Group Calendar List by Day

Posted: Wed Oct 07, 2015 10:52 pm
by cpansewicz
Thanks! Thanks! Thanks! That worked perfectly. I appreciate the assistance very much.