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.

Template Questions /

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

limiting childrenof

Go to End

2 Posts   1478 Views


Community Member, 47 Posts

21 May 2010 at 8:42am

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:

Anyone know of a way?


Community Member, 135 Posts

25 May 2010 at 1:16pm

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: