[MAGNOLIA-7853] TemplatingFunctions: collectAllChildren is needed -> add getNodeUtil() & getPropertyUtil() Created: 23/Jul/20  Updated: 23/Jul/20

Status: Open
Project: Magnolia
Component/s: templating
Affects Version/s: 6.2.2
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Christian Ringele Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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)

 Description   

In templating its pretty cumbersome to collect all nodes from a certain type within a workspace, no matter how deep they are located in the workspace (folders etc).

In Java simply achieved:

Iterable<Node> childrenIterable = NodeUtil.collectAllChildren(jcrSession.getRootNode(),new NodeTypePredicate("mgnl:contact", true));

In Freemarker it would be nice to have something alike this (workspace, nodeType):

[#assign allContacts = cmsfn.collectAllChildren("contacts", "mgnl:contact")]

In a template one needs to code a recursion/macro for it.

 

Also it would be nice do be able to directly access the NodeUtil and the PropertUtil directly:
Something alike

[#assign nodeUtil = cmsfn.nodeUtil]
[#assign propertyUtil = cmsfn.propertyUtil]

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