Question

I'm working with Silverstripe and I'm trying to find out how many children a page has. How could I best do this from the Page_Controller class?

What I'm looking to do is to calculate the height that a navigation DIV in my template should be based on the number of children that it has to display. So I'm looking to right a function that returns [# of Children] * [Height per Child].

Can anyone advise me how I could go about getting # of children to a Page object?

Was it helpful?

Solution

ArrayList has a count() function that will return you the number of items in the list.

You can call count() on your page Children list.

$this->Children()->count();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top