[SOLVED] Wrong month displaying on CGCalendar

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
JackOutoftheBox
Forum Members
Forum Members
Posts: 89
Joined: Thu Jan 25, 2007 8:05 pm

[SOLVED] Wrong month displaying on CGCalendar

Post 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:

Code: Select all

{$month_names[$month]}
... but it is showing one month ahead. Otherwise the calendar dates display fine.

Can anyone shed some light?
Last edited by JackOutoftheBox on Wed Jul 02, 2014 1:24 pm, edited 2 times in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Wrong month displaying on CGCalendar

Post by velden »

JackOutoftheBox
Forum Members
Forum Members
Posts: 89
Joined: Thu Jan 25, 2007 8:05 pm

Re: Wrong month displaying on CGCalendar

Post 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}
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: Wrong month displaying on CGCalendar

Post by paulbaker »

Did you try staartmees' solution? It worked for me.

Change

Code: Select all

{$month_names[$month]} into {$month_names[$month-1]}
JackOutoftheBox
Forum Members
Forum Members
Posts: 89
Joined: Thu Jan 25, 2007 8:05 pm

Re: [SOLVED] Wrong month displaying on CGCalendar

Post by JackOutoftheBox »

Yep, that did it. Thanks so much. :)
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: [SOLVED] Wrong month displaying on CGCalendar

Post by Rolf »

Change

Code: Select all

{$month_names[$month]}
into

Code: Select all

{$date|date_format:'%B'}
or

Code: Select all

{$thedate|date_format:'%B'}
This is depending on the type of template you change

grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Locked

Return to “Modules/Add-Ons”