[MAGNOLIA-1275] <cms:out inherit="true"> does not work with <cms:includeTemplate contentNode="..."> set Created: 15/Dec/06  Updated: 04/Nov/15  Resolved: 04/Nov/15

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Daniel Bleisteiner Assignee: Fabrizio Giustina
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
dependency
is depended upon by MAGNOLIA-2993 Extract logic out of taglibs - reusab... 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   

I'm using <cms:includeTemplate contentNode="..."> to include templates which use <cms:out inherit="true"> themself. That inherit="true" does not work in that case. Only local properties are printed - parent node's properties are not found. This issue is related to MAGNOLIA-1272 and should affect all cases where Resource.getLocalContentNode(request) Unable to render embedded object: File (= null) not found.

As far as I have analyzed this issue the problem lies in BaseContentTag#resolveNode(Content)! This method uses a local variable currentParagraph. If this variable != null (in case of a local conent node) and no contentNodeName or contentNodeCollectionName is set it simply returns the local content node referenced by currentParagraph. It never returns the node with the property we are looking for.

if (contentNodeName == null && contentNodeCollectionName == null)

{ // e.g. <cms:out nodeDataName="title"/> return currentParagraph; }

To come back to my problem... the following code in BaseContentTag#getFirstMatchingNode() never returns the desired node because it won't be returned by resolveNode(Content):

while (inherit && currentPage.getLevel() > 0 && !nodeData.isExist())

{ currentPage = currentPage.getParent(); contentNode = resolveNode(currentPage); nodeData = contentNode.getNodeData(this.nodeDataName); }

The contentNode stays the local content node all over the while loop and is returned in the end.

That's all for the moment... I'll try to solve this for my local installation and report my changes later... but I don't have the total overview of possible sideeffects. We'll see that I can do...



 Comments   
Comment by Daniel Bleisteiner [ 15/Dec/06 ]

I'd use the following solution:

1st search from the local content node upwards if set - not the request page!
2nd change the returned value within resolveNode in case of local set content node!

Here is my local patch... please have a closer look. I found no reason why the original return within resolveNode returns the local content node - it has nothing to do with the currentPage parameter given. But I could oversee some other sideeffects - maybe there is another reoson for returning that local content node instead of the given currentPage parameter.

Index: /home/daniel/Software/magnolia/magnolia-taglib-cms/src/main/java/info/magnolia/cms/taglibs/BaseContentTag.java
===================================================================
— /home/daniel/Software/magnolia/magnolia-taglib-cms/src/main/java/info/magnolia/cms/taglibs/BaseContentTag.java (revision 6740)
+++ /home/daniel/Software/magnolia/magnolia-taglib-cms/src/main/java/info/magnolia/cms/taglibs/BaseContentTag.java (working copy)
@@ -88,7 +88,8 @@
protected Content getFirtMatchingNode() {

HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

  • Content currentPage = Resource.getCurrentActivePage(request);
    + Content currentPage = Resource.getLocalContentNode(request);
    + if (currentPage == null) currentPage = Resource.getCurrentActivePage(request);
    Content contentNode = resolveNode(currentPage);
    if (contentNode == null) {
    return null;
    @@ -150,7 +151,7 @@
    // inside collection iterator
    if (contentNodeName == null && contentNodeCollectionName == null) { // e.g. <cms:out nodeDataName="title"/> - return currentParagraph; + return currentPage; //currentParagraph; }

    else if ((contentNodeName != null && StringUtils.isEmpty(contentNodeName))

    (contentNodeCollectionName != null && StringUtils.isEmpty(contentNodeCollectionName))) {
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 03:25:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.