Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Count value for number of Children

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

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

Page: 1
Go to End
Author Topic: 2992 Views
  • fishe
    Avatar
    Community Member
    42 Posts

    Count value for number of Children Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Count value for number of Children Link to this post

    $Children.Count should work.

    2992 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.