Page 1 of 1
[SOLVED] Wrong month displaying on CGCalendar
Posted: Tue Jul 01, 2014 6:16 pm
by JackOutoftheBox
After a recent sever move and system upgrade of all the software on a CMS-powered site by a client's internal tech team, the CGCalendar went wacky and I've been charged with making some repairs.
The main issue I can't fix is the WRONG month is displaying at the top of the grid monthly calendars.
Is this related to something on the server (could the date be wrong somewhere I can't control) or something internally?
The calendar template calls this:
... but it is showing one month ahead. Otherwise the calendar dates display fine.
Can anyone shed some light?
Re: Wrong month displaying on CGCalendar
Posted: Tue Jul 01, 2014 6:39 pm
by velden
Re: Wrong month displaying on CGCalendar
Posted: Wed Jul 02, 2014 11:13 am
by JackOutoftheBox
Thank you for the post. I had actually already used that in my upcoming list templates as a work-around.
What I haven't found a solution for is the GRID templates that show the month. The smarty %B code isn't recognized there. This is addressed in the link you posted.
Looks like you still need month_name stuff in some templates (e.g. the main monthly view with next and previous links) where staartmees's solution works well.
Any ideas for this problem? Here's my current template code:
Code: Select all
{strip}
<table class="calendar" id="cal-calendar">
<div class="calendar-month"><span class="calendar-prev"><a href="{$navigation.prev}">«</a></span> {$month_names[$month]} {$year} <span class="calendar-next"><a href="{$navigation.next}">»</a></span></div>
<tbody><tr>
{foreach from=$day_names item=day key=key}
<th abbr="{$day}">{$day_short_names[$key]}</th>
{/foreach}</tr>
<tr>
{* initial empty days *}
{if $first_of_month_weekday_number > 0}
<td colspan="{$first_of_month_weekday_number}"> </td>
{/if}
{* iterate over the days of this month *}
{assign var=weekday value=$first_of_month_weekday_number}
{foreach from=$days item=day key=key}
{if $weekday == 7}
{assign var=weekday value=0}
</tr>
<tr>
{/if}
<td {if isset($day.class)}class="{$day.class}"{/if}>
{if isset($day.events.0)}{$key}
<ul>
{foreach from=$day.events item=event}
<li><a href="{$event.url}">X</a></li>
{/foreach}
</ul>
{else}{$key}{/if}
</td>
{math assign=weekday equation="x + 1" x=$weekday}
{/foreach}
{* remaining empty days *}
{if $weekday != 7}
<td colspan="{math equation="7-x" x=$weekday}"> </td>
{/if}
</tr>
</tbody></table>
{/strip}
Re: Wrong month displaying on CGCalendar
Posted: Wed Jul 02, 2014 1:05 pm
by paulbaker
Did you try staartmees' solution? It worked for me.
Change
Code: Select all
{$month_names[$month]} into {$month_names[$month-1]}
Re: [SOLVED] Wrong month displaying on CGCalendar
Posted: Wed Jul 02, 2014 1:24 pm
by JackOutoftheBox
Yep, that did it. Thanks so much.

Re: [SOLVED] Wrong month displaying on CGCalendar
Posted: Wed Jul 02, 2014 4:57 pm
by Rolf
Change
into
or
This is depending on the type of template you change
grtz. Rolf