For a site I would like to make a calendar on the frontpage which lists upcoming events.
My idea idea is to do it in this way:
MONTH
-DATE
-TITLE
------------
-DATE
-TITLE
------------
MONTH
-DATE
-TITLE
Is it possible to group calendar events by month? Maybe by keeping a variable for the current month and if the month variable differs from the kept variable add a month title?
[CGCalendar] Group events by month
Re: [CGCalendar] Group events by month
Found a solution for this. Will post my code for someone else to use.
Code: Select all
{assign var=month_check value=""}
{foreach from=$events key=key item=event}
{assign var=month_number value=$event.event_date_start|date_format:"%m"}
{assign var=end_month_number value=$event.event_date_end|date_format:"%m"}
{if $month_check == ""}
{assign var=month_check value=$month_number}
<h2>{$event.event_date_start|date_format:"%B"}</h2>
{elseif $month_check != $month_number}
<h2>{$event.event_date_start|date_format:"%B"}</h2>
{assign var=month_check value=$month_number}
{/if}
rest of the calendar markup
{/foreach}