[MAGNOLIA-5029] Components with areas does not behave as expected on a public instance: areas are displayed even if they are empty Created: 20/Jul/12 Updated: 25/Jun/13 Resolved: 16/May/13 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 4.5.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Samuel Schmitt | Assignee: | Jaroslav Simak |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Template: |
|
||||||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||||||||||||||
| Date of First Response: | |||||||||||||||||||||
| Description |
|
On a public instance, components that have in their configuration areas defined do not behave as expected while this behavior is correct on the author instance. On the public, even if the area is not existing , the component displays it. Let's take an example. Inspect the HTML code of the "Standard Article" on both page. Standard article is a STK Teaser, its configuration is stkTeaser. And this area has as a template script /templating-kit/components/teasers/linkListArea.ftl that renders this HMTL code <div class="links"> [#if (content.title)??] <${headingLevel}>${content.title}</${headingLevel}> [/#if] <ul> [#list components as component ] [@cms.component content=component /] [/#list] [#if cmsfn.editMode] <li cms:add="bar"></li> [/#if] </ul> </div><!-- end links --> But why this code is rendered on public and not on author.
So I think that the problem comes from the tag cms.area. In internalPage.ftl [#-- Rendering the teaser's linkList --]
[@cms.area name="linkList"/]
The tag should not render the area linkList as it's not existing. |
| Comments |
| Comment by Jan Haderka [ 03/May/13 ] |
Actually this is not completely true. The empty div is rendered also on author when not in preview mode. In preview mode it is skipped because: AreaElement.java
private boolean canRenderAreaScript() {
// FYI: areaDefinition == null when it is not set explicitly and can't be merged with the parent. In such case we will render it as if it was enabled
return this.isAreaDefinitionEnabled && (areaNode != null || (areaNode == null && areaDefinition.isOptional() && !MgnlContext.getAggregationState().isPreviewMode()));
}
Values:
|
| Comment by Jan Haderka [ 13/May/13 ] |
|
Changing the template script is good as temporary workaround, but can't be final solution. There are other areas that can be used under components and they all suffer from same problem. This is why we need to solve it from within canRenderAreaScript() method. |
| Comment by Jan Haderka [ 15/May/13 ] |
|
just a tiny thing, but helps to understand the code next time there's some bug to fix:
if (!((AreaDefinition.TYPE_LIST.equals(areaDefinition.getType()) || AreaDefinition.TYPE_SINGLE.equals(areaDefinition.getType())) && numberOfComponents < 1)) {
272
is not really easy to read, partly because it is long and partly because of the negation of the whole statement. Can we maybe just swap if/else parts of the code below so the test expression doesn't have to be negated? Also IIRC expressions are evaluated left to right so I would put the simple (numberOfComponents < 1) test first because if that is not satisfied, there's no need to evaluate the rest ... but that's really nitpicking. |