Jump to:

3443 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » limiting childrenof

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

Page: 1
Go to End
Author Topic: 1092 Views
  • netnerd85
    Community Member
    42 Posts

    limiting childrenof Link to this post

    I'm trying to use ChildrenOf but limit the amount of results, I tried the following and it did not work for me:

    <% control ChildrenOf(blog) %>
    <% control Range(0,3) %>
    <% end_control %>
    <% end_control %>

    The code above is from here: http://www.silverstripe.org/archive/show/160555#post160555

    Anyone know of a way?

  • 3dgoo
    Community Member
    133 Posts

    Re: limiting childrenof Link to this post

    I can't find any information about the control Range, and I can't get it to work. So I assume this was a feature of 2.2 that was dropped in 2.3.

    What you could do is create a function to do this in your Controller:

    function BlogEntries()
       return DataObject::get("BlogEntry", NULL, NULL, NULL, "0, 3");

    In your template:

    <% control BlogEntries %>
    <% end_control %>

    Check out DataObject::get to see the parameters for sorting and where clauses if you need them:

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.