Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Count value for number of Children


Go to End


2 Posts   5779 Views

Avatar
fishe

Community Member, 42 Posts

11 January 2009 at 4:34pm

I have a page type class with a parent page type class, like the ArticlePage and ArticleHolder relationship in tutorial 2, by setting $allowed_children.

I need a count value of the number of children in a page of type ArticleHolder (in a .ss file). What would be the best way to go about this? I'm not sure where the code should go.

I know I can do things like <% control Children %> to iterate through the children, although I haven't come across a straightforward way to get a count of the number of children as a $variable.

Thanks in advance

Avatar
UncleCheese

Forum Moderator, 4102 Posts

11 January 2009 at 4:58pm

$Children.Count should work.