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?

有帮助吗?

解决方案

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();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top