[MAGNOLIA-2669] <cms:out inherit="true" fails Created: 24/Mar/09  Updated: 23/Jan/13  Resolved: 07/Aug/09

Status: Closed
Project: Magnolia
Component/s: templating
Affects Version/s: 4.0.1
Fix Version/s: 4.0.3, 4.1.1

Type: Bug Priority: Critical
Reporter: Oliver Knorr Assignee: Jan Haderka
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows Vista Business SP1
JDK 1.6.0_11
apache-tomcat-5.5.26
magnolia-bundled-webapp-4.0.1.war


Attachments: Text File BaseContentTage.java.patch    
Issue Links:
relation
is related to MAGNOLIA-2671 <cmsu:simpleNavigation relativeLevels... Closed
is related to MAGNOLIA-2806 contentNodeIterator tag doesn't inher... Closed
supersession
is superseded by MAGNOLIA-2869 taglibs: inheritance in iterator and ... Closed
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   

After upgrading from Magnolia 3.6.3 to 4.0.1, cms:out-Tags stopped printing values inherited from parent pages. For example: <cms:out nodeDataName="copyright" inherit="true" /> prints something only, if the copyright-field is filled for the page, but no longer if it is filled only for the parent page.

Some debugging showed a different code path in BaseContentTag.resolveNode() because of different results from Resource.getLocalContentNode().

This seems to be caused by the changes for MAGNOLIA-2642. If I revert Resource.java to the previous revision (from http://svn.magnolia-cms.com/view/community/magnolia/trunk/magnolia-taglib-cms/src/main/java/info/magnolia/cms/taglibs/Resource.java?revision=21024), the inherited fields work fine for me.



 Comments   
Comment by Tom Wespi [ 24/Mar/09 ]

if the inherited value is not stored in a contentNodeCollectionName, you have to pass the empty attribute.

<cms:out nodeDataName="metaDescription" inherit="true" var="metaDescription" contentNodeCollectionName=""/>

this is working for me.

Comment by Oliver Knorr [ 24/Mar/09 ]

Thanks a lot Tom for the suggestion, it also works for me. I have reduced the priority to minor. However, I don't think this empty attribute should be necessary, this is only a workaround.

Comment by Will Scheidegger [ 21/Jul/09 ]

At least for tags outside of a content node iterator the problem actually seems to be related to the way how the deprecated Resource class works now. Resource.getLocalContentNode() simply returns AggregationState.getCurrentContent() which is always set to the local content node OR the current active page if one is not inside a content node iterator. Therefore the resolveNode() method of the BaseContentTag class always thinks that the tag is inside a content node iterator and therefore does not work properly.

Simply comparing the handle of the local contente node returned by the Resource class with the active current page fixes this problem. Since this is a hack and not really a fix I did not provide a patch but here are the first few lines of my modified BaseContentTag.resolveNode() methode if you need a quick fix:

    protected Content resolveNode(Content currentPage) {
        Content currentParagraph = Resource.getLocalContentNode();
        if (currentParagraph != null && currentParagraph.getHandle().equals(Resource.getCurrentActivePage().getHandle())) {
            currentParagraph = null;
        }

       //... rest of the method
}
Comment by Magnolia International [ 21/Jul/09 ]

can you please provide patches in patch form ?
See http://documentation.magnolia-cms.com/contribute.html

Comment by Will Scheidegger [ 21/Jul/09 ]

Grégory

As I said in my comment above, I could provide a this fix as patch, but won't because it's a quick hack which still makes use of the Resource class. Once I got the new AggregationState figured out properly, I will be happy to provide a patch.

Comment by Will Scheidegger [ 21/Jul/09 ]

This to some degree less ugly hack (Attachement 1 above) fixes the inherit problem on the cms:out tag (most likely on all tags extending BaseContentTag). Still to improve: The patch still uses the deprecated Resource class because one test failed when I tried to use MgnlContext.getAggregationState().getMainContent() instead of Resource.getCurrentActivePage().

Comment by Oliver Knorr [ 21/Jul/09 ]

Dear Will and Grégory,
please note there is the similar issue MAGNOLIA-2671 with the SimpleNavigationTag. This is also related to the change on the Resource class, but SimpleNavigationTag is not extending BaseContentTag. I have linked the JIRA issues now. I'm sorry I don't know enough of Magnolia internals to understand how Resource, MgnlContext etc. are supposed to work.

Comment by Jan Haderka [ 07/Aug/09 ]

Applied with few modifications and fixed tests. Thanks for patches.

Generated at Mon Feb 12 03:38:57 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.