[MAGNOLIA-1272] <cms:includeTemplate> ignores contentNode if defined for the tag Created: 14/Dec/06  Updated: 23/Jan/13  Resolved: 22/Oct/07

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 3.0 Final
Fix Version/s: 3.5 RC1

Type: Bug Priority: Critical
Reporter: Daniel Bleisteiner Assignee: Vivian Steller
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: 1h
Time Spent: Not Specified
Original Estimate: 1h

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've tried to use <cms:includeTemplate contentNode="${myNode}" path="/path/to/jsp" /> to embed JSPs with <cms:out> data filled from a random content node object. After a while I figured out that the content node is never actually used by the tag if defined!

Check info.magnolia.cms.taglibs.Include#doEndTag(...) and the local variable "content". If set, it is never actually used for anything else then aquiring the template path (if not set). So I've fixed this for my local installation by adding the following code:

Content content = this.contentNode;
if (content == null)

{ // SNIPPED }

// DANIEL BLEISTEINER
if (content != Resource.getCurrentActivePage(req) && !localContentNodeSet && content != null)

{ Resource.setLocalContentNode(req, content); localContentNodeSet = true; }

I had strange experiences using contentNode="${actpage}" within the JSP and had to check for that case. Maybe you know better.

Related to that I found out that <cms:out inherit="true"/> traverses the request context path up and not the local content node's path I set. Is this intended?



 Comments   
Comment by Philipp Bracher [ 15/Dec/06 ]

Thank you. I think you are completely right, but I need to have a deeper look at the problem at first.

If possible, please add next time a patch (this facilitates applying code changes and avoids missanderstandings)

Comment by Vivian Steller [ 22/Oct/07 ]

included your code snippet. Thanks for your help, Daniel.

> Related to that I found out that <cms:out inherit="true"/> traverses the request context path up and not the local content node's path I set. Is this intended?
I think that this is not true (at least anymore): as far as I can see BaseContentTag uses currentPage.getParent() (line 139) to traverse the tree to the root.
Please correct me if I'm wrong and open a new issue if you think this should still be changed.

Thanks again for your help.

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