CMS MADE SIMPLE FORGE

CGCalendar

 

[#10088] Sample Smarty Template has month bug - solution included

avatar
Created By: Kenneth Griffith (kendo451)
Date Submitted: Wed Jul 02 05:24:13 -0400 2014

Assigned To: Robert Campbell (calguy1000)
Version: 1.7.4
CMSMS Version: 1.11.10
Severity: Minor
Resolution: Invalid
State: Closed
Summary:
Sample Smarty Template has month bug - solution included
Detailed Description:
The default list template(s) attempt to assign the month using strftime %m to a
variable $month_number.  ($event.event_date_start|date_format:"%m")

Then in the display this month_number is used as an index to the month_names
array like this:

$month_names[$month_number]

The problem is that %m yields a two-digit month number, such as 01 for January. 
The month_number array uses 0 for January.

01 is interpreted by Smarty as a string, and $month_names['01'] is null, so no
month name is displayed.

There are several ways to fix this problem.  Below is my way.

Solution:

Step 1. Delete these two lines that assign the month number:
{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"}

Step 2. Find and Replace Start Month

Replace This: {$month_names[$month_number]}
With This: {$event.event_date_start|date_format:"%B"}

Step 3. Find and Replace End Month

Replace This: {$month_names[$end_month_number]}
With This: {$event.event_date_end|date_format:"%B"}


History

Comments
avatar
Date: 2014-12-28 23:40
Posted By: Robert Campbell (calguy1000)

month names array is no longer used.
      
Updates

Updated: 2015-01-15 23:39
state: Open => Closed

Updated: 2014-12-28 23:40
resolution_id: => 9