I want the ArticleHolder.ss (as per the tutorial) to only display the first 3 Children.
Any ideas anyone?
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.
Hi Noel,
Give this a go:
http://www.silverstripe.org/template-questions/show/270374
thanks for that - I'm a bit of a novice on all this ....
so I've figured out that the function needs to be declared in the php controller
- but I'm a but confused about how to 'call' this function inside (?) the .ss <% control Children %> loop
You're doing well by asking questions.
So you have a function in your controller something like this:
public function GetChildren($Limit = 5){
return DataObject::get("PageType", "ParentID = $this->ID", Null, Null, $Limit);
}
In your template you would have:
<% control GetChildren(3) %>
<h2>$Title</h2>
$Content.LimitWordCount
<% end_control %>
You call the control on GetChildren instead of Children.
Make sense?
cool - thanks mate - much appreciated !!!