[CGCalendar] Group events by month

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

[CGCalendar] Group events by month

Post by vinyl »

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?
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

Re: [CGCalendar] Group events by month

Post by vinyl »

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}

Post Reply

Return to “Modules/Add-Ons”