I am looping all the nodes in a map with c.findAll().each { n -> ... } and I would like to know if it is possible to know what is the current node's depth level?
Thanks,
Alexandre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am looping all the nodes in a map with c.findAll().each { n -> ... } and I would like to know if it is possible to know what is the current node's depth level?
Thanks,
Alexandre
I did a function that returns a nodes' depth:
Usage:
Always call with '0' as the second parameter.
Alexandre
You could also use the builtin node.getNodeLevel or node.pathToRoot. This is especially handy in formulas:
Last edit: Volker Börchers 2016-11-29
Thanks Volker I didn't know that function, I replaced my code.
Hi Volker,
Actually what you think is the Elvis operator is the safe navigation operator.
https://en.wikipedia.org/wiki/Safe_navigation_operator
The Elvis operator is a shorter variant of the ternary operator:
https://en.wikipedia.org/wiki/Elvis_operator
But thanks anyway nice to know these.
Best regards,
Alexandre
Impressed about these little details of Groovy, so very flexible...
On 30 Nov 2016 07:16, "Alexandre" alexandreviau77@users.sf.net wrote: