3

In my template I'm displaying all entries of a structure: ('areas').level(1) using a loop.

I would also like to display the number of children entries in each of the 'areas'.

Like: "Area 1, 4 properties", "Area 2, 7 properties", "Area 3, 5 properties" and so on.

Anyone?

2

If you want all the descendent too you can use:

{% set totalDescendents = entry.getDescendants().count() %}

https://buildwithcraft.com/docs/templating/entrymodel#getDescendants

1

You could get the number of direct children using this:

{% set numChildren = entry.children().count() %}

I'm not sure if there's an efficient solution to getting the full number of children, grandchildren etc. without just comparing against the URL which seems like a workaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.