[MAGNOLIA-2267] Provide easy access to content parent in freemarker paragraph Created: 16/Jul/08  Updated: 23/Jan/13  Resolved: 22/Jan/09

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

Type: Improvement Priority: Major
Reporter: Jan Haderka Assignee: Jan Haderka
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to MAGNOLIA-2366 Provide access to commonly used objec... 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)
Date of First Response:

 Description   

Currently there is no simple way to obtain parent of current piece of content in freemarker paragraph. Ideally something like ${content.parent} would provide access to the content parent.
It can be achieved by simple change in i.m.f.ContentModel



 Comments   
Comment by Magnolia International [ 16/Sep/08 ]

Not convinced about the ${content.parent} syntax since that could conflict with the (very unlikely, indeed) existence of a child node called parent.
${content.getParent()} otoh probably already works.

Comment by Philipp Bracher [ 18/Sep/08 ]

the problem is the consistency between jsp and freemarker. content.getParent() does not work in EL.

Anyway if we implement the following resolution rules:

  • nodedata
  • child node
  • property

it will work fine for 99%. In case you have a nodedata = getter conflict and you don't want the nodedata value (which is less likely in templates) you can fall back to the explicit method notation.

Comment by Magnolia International [ 18/Sep/08 ]

fair enough
needs tests - it might already work for freemarker

Comment by Magnolia International [ 30/Sep/08 ]

While indeed not consistent with jsp EL, I just realized this is already possible using ${content?parent} - see i.m.freemarker.ContentModel.getParent()

Comment by Jan Haderka [ 22/Jan/09 ]

Resolved by MAGNOLIA-2366 which is exposing all commonly needed objects and their properties.

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