Cette conversation a été verrouillée en raison de son inactivité. Veuillez créer une nouvelle publication.
Niveau 1
Niveau 2
Se connecter à la communauté
Connectez-vous pour voir tous les badges
Cette conversation a été verrouillée en raison de son inactivité. Veuillez créer une nouvelle publication.
Hi Community,
I am looking for standard/easy way to find the size of the first level children of the root responsive grid node. I understand that we can do it in jave/javascript code with list-children and find the size.
Is there any simple way in HTL itself to find that root node has children or not. if possible with size also.
Résolu ! Accéder à la solution.
Vues
Réponses
Nombre de J’aime
@srikanthg212933 Below code should give you the number of child nodes in the immediate parent of your current node
<sly data-sly-test="${currentNode.parent.hasNodes}">
Size is - ${currentNode.parent.nodes.size}
</sly>
, assuming your current component is inside the responsive grid node , the above code will get the number of nodes under the responsive grid
For eg : In my case I have 7 nodes under the responsive grid
And the above code outputs me Size is - 7
Vues
Réponses
Nombre de J’aime
@srikanthg212933 Below code should give you the number of child nodes in the immediate parent of your current node
<sly data-sly-test="${currentNode.parent.hasNodes}">
Size is - ${currentNode.parent.nodes.size}
</sly>
, assuming your current component is inside the responsive grid node , the above code will get the number of nodes under the responsive grid
For eg : In my case I have 7 nodes under the responsive grid
And the above code outputs me Size is - 7
Vues
Réponses
Nombre de J’aime
Thanks for the reply. I am looking for similar size function for the child root node. I have responsive grid inside a component in our case. Any similar support we have for navigating to child node from currentNode object.
Vues
Réponses
Nombre de J’aime
There is no getChild() method in https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html , instead we have getNodes() which will return the child nodes of the current node. So you have to do something like
<sly data-sly-test="${currentNode.hasNodes}">
Size is - ${currentNode.nodes.size}
</sly>
Vues
Réponses
Nombre de J’aime
Vues
Likes
Réponses
Vues
Likes
Réponses
Vues
Likes
Réponses