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();
Frage
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?
Lösung
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();