3217 Posts in 853 Topics by 812 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 974 Views |
-
limiting childrenof

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) %>
$Content
<% end_control %>
<% end_control %>
The code above is from here: http://www.silverstripe.org/archive/show/160555#post160555Anyone know of a way?
-
Re: limiting childrenof

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 %>
$Content
<% end_control %>Check out DataObject::get to see the parameters for sorting and where clauses if you need them:
http://doc.silverstripe.org/datamodel#querying_data
| 974 Views | ||
|
Page:
1
|
Go to Top |


