Page 1 of 1

Multiple calendars with dynamic month/year calculation

Posted: Sat Mar 08, 2008 11:33 am
by RonnyK
I needed 3 calendars on a page, but couldnt find a script that did this. There where logics with fixed months/years, but nothing dynamically, so I ended up with writing the following logic.....

I created a GCB, where I inserted this logic, the GCB is then called in the template, where the calendars should appear.

Code: Select all

{assign var=maand value=$smarty.now|date_format:"%m"} 
{assign var=jaar value=$smarty.now|date_format:"%Y"} 

{cms_module module="Calendar" month=$maand year=$jaar} 
{if $maand gt 11} 
{assign var=maand1 value=$maand+1-12} 
{assign var=jaar1 value=$jaar+1} 
{cms_module module="Calendar" month=$maand1 year=$jaar1} 
{else} 
{assign var=maand2 value=$maand+1} 
{cms_module module="Calendar" month=$maand2 year=$jaar} 
{/if} 
{if $maand gt 10} 
{assign var=maand3 value=$maand+2-12} 
{assign var=jaar3 value=$jaar+1} 
{cms_module module="Calendar" month=$maand3 year=$jaar3} 
{else} 
{assign var=maand4 value=$maand+2} 
{cms_module module="Calendar" month=$maand4 year=$jaar} 
{/if} 
Ronny

Re: Multiple calendars with dynamic month/year calculation

Posted: Sat Apr 10, 2010 2:28 pm
by Peciura
And this is template for multiple instances of  CGCalendar. I have modified RonnyK's template dropped to pastebin.
You will have to set number of columns and number of months you want to show.
{assign var='col_num' value='2'}{*number of columns*}
{assign var='month_num' value='5'}{*number of months to be displayed*}

{assign var='current_month' value=$smarty.now|date_format:"%m"}
{assign var='current_year' value=$smarty.now|date_format:"%Y"}



{section name='months' start=$current_month loop="`$current_month+$month_num`"}
{assign var='month' value="`$smarty.section.months.index%12`"}
{if $month==0}
{assign var='month' value='12'}
{/if}
{if 1=="`$smarty.section.months.iteration%$col_num`"}

{/if}
{assign var='year' value="`$current_year+$smarty.section.months.index/12`"|intval}

{cms_module module="CGCalendar" year=$year month=$month first_day_of_week='0'}{*  CGCalendar call *}

{if 0==$smarty.section.months.iteration%$col_num}

{/if}
{/section}


Re: Multiple calendars with dynamic month/year calculation

Posted: Sat Apr 10, 2010 6:23 pm
by cyberman
Great thing - thx!

Got some support requests in the past for things like this.

Re: Multiple calendars with dynamic month/year calculation

Posted: Thu Apr 22, 2010 5:20 pm
by Peciura
One will have more fun if months can be switched inline and independently http://forum.cmsmadesimple.org/index.ph ... #msg206300

Re: Multiple calendars with dynamic month/year calculation

Posted: Fri Sep 23, 2011 1:56 pm
by DaRichMan
@ Peciura (and any other who knows);

Thanx to your example I ended up with almost the look I want. One little thing, if there is an event in the calendar it shows the name of it in the calendar (see sreenshot).
Is it possible to make the days which contain an event clickable and not show the title of the event?

Re: Multiple calendars with dynamic month/year calculation

Posted: Fri Sep 23, 2011 5:58 pm
by RonnyK
Sure,

remove the call in the a-href that shows the {$event.event_details}. Just remove that part, make sure that the day-remains clickable.

Ronny