[MGNLSTK-808] CalendarModel's getWeeksInMonth method returns 1 for months having less than 31 days Created: 31/Oct/11  Updated: 04/Nov/15  Resolved: 04/Nov/15

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: paragraphs
Affects Version/s: 1.4.5
Fix Version/s: Backlog

Type: Bug Priority: Neutral
Reporter: Matt Dertinger Assignee: Philipp Bärfuss
Resolution: Won't Do Votes: 0
Labels: stk
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File c-e-com-november-events.png    
Template:
Acceptance criteria:
Empty
Date of First Response:
Visible to:
Mark Montri, Yun Qian

 Description   

Hi,

Currently, it looks like the STK's CalendarModel's getWeeksInMonth method returns 1 for months having less than 31 days. As an example, see the stkExtrasCalendar paragraph, you can see the resulting behavior on the demopublic site here: http://demopublic.magnolia-cms.com/demo-project/news-and-events/events-overview.2011.11.html

Notice, only the first week of the month is displayed. If you cycle through the months, you'll notice that months that have 31 days display all weeks of the month, while those having less than 31 days only display the first week.

Note: For some reason, calling the model.weeksInMonth in the freemarker template before the list 1 .. model.weeksInMonth as x seems to fix the display issue. Here's an example:

templating-kit/paragraphs/features/calendar.ftl
<tbody>
    <tr>
        <td colspan="7">${model.weeksInMonth!}</td>
    </tr>
    [#list 1 .. model.weeksInMonth as x]
        <tr>
            <th class="cw">${model.getCalendarItem(x, 1).week}</th>
            [#list 1 .. 7 as y]
                [#assign item = model.getCalendarItem(x, y)]
                <td ${cmsfn.createAttribute("class", item.cssClass)}>
                    [#if item.visible]
                        [#if item.link??]
                            <a href="${item.link}">${item.day}</a>
                        [#else]
                            ${item.day}
                        [/#if]
                    [/#if]
                </td>
            [/#list]
        </tr>
    [/#list]
</tbody>

Note: I've also fixed the markup in the example above, in the actual source code, the anchor tag isn't closed and the closing td tag is in the wrong location. That issue has already been reported here: MGNLSTK-686

Please let me know if you have any additional questions.

Cheers,
Matt



 Comments   
Comment by Christian Ringele [ 01/Nov/11 ]

Hi Matt,

When opening the link you added, the calendar opens as expected showing all weeks of the month.
Can you add a print screen on how the calendar appears in your browser.
I'm wondering if this could be related of different calendar definitions for US -> Week starts on Sunday and not on Monday.

Christian

Comment by Matt Dertinger [ 01/Nov/11 ]

Hi Christian,

It's peculiar. Yesterday the demopublic link I referenced wasn't showing the other weeks. However, today it is displaying properly. The same thing was happening on some other instances we were running, which look ok today. However, we are still getting the issue on c-e.com. I've attached a screenshot.

If it helps, we have been testing in Google Chrome with the following locale settings in the request header:

Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Language:en-US,en;q=0.8

Cheers,
Matt

Comment by Matt Dertinger [ 01/Nov/11 ]

Hi Christian,

We just activated the revised template I submitted a patch for on MGNLSTK-686. The process of activating it seemed to do something to correct the issue. Note: I don't think it was related to the template fixes themselves, since the template on the demopublic site is still the original, and it is currently working. Could caching have anything to do with this behavior?

Cheers,
Matt

Comment by Michael Mühlebach [ 04/Nov/15 ]

Given the thousands of other issues we have open that are more highly requested, we won't be able to address this issue in the foreseeable future. Instead we will focus on issues with a higher impact, and more votes.
Thanks for taking the time to raise this issue. As you are no doubt aware this issue has been on our backlog for some time now with very little movement.
I'm going to close this to set expectations so the issue doesn't stay open for years with few updates. If the issue is still relevant please feel free to reopen it or create a new issue.

Generated at Mon Feb 12 07:30:37 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.