17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2828 Views |
-
1st, 2nd, .... child of children

30 October 2007 at 9:46pm
Hello,
how do I get the 1.,2.,... child of a children list? I do not wan't to iterate through them but just access the first 4 individually.
Thanks
-stephan -
Re: 1st, 2nd, .... child of children

30 October 2007 at 9:59pm
I am new to sliver stripe
can u help me on thishow to place a dropdown control on middle of my page
-
Re: 1st, 2nd, .... child of children

31 October 2007 at 10:22am Last edited: 31 October 2007 10:22am
Put this function in your Page class.
function LimitedChildren($limit) {
return DataObject::get("SiteTree", "ParentID = $this->ID", null, $limit);
}then you can put this in your template:
<% control LimitedChildren(4) %>
...
<% end_control %> -
Re: 1st, 2nd, .... child of children

1 November 2007 at 9:53am
Thanks for the reply, I more wanted to do
<% control child(1) %>
...
<% end_control %>to access them individually for filling their content into slots
Thanks
-stephan -
Re: 1st, 2nd, .... child of children

1 November 2007 at 4:54pm Last edited: 1 November 2007 4:56pm
Well $limit is just the LIMIT clause of SQL; so, you could make it if you changed it to "$limit, 1", then that would return you the nth item.
If you wanted to use a single SQL query, you could have the function get all the items and save them to a local parameter the first time it was called, and after that just request from the object.
Long story short: There's nothing built-in for this, but it's only a few lines of PHP away...
Of course, I should probably mention why there's no feature to support that: in the 100s of sites we've built with SilverStripe, we've never needed that feature. Why? Because that kind of design inhibits your ability to add an extra item to the menu, with prevents your author from making the information architecture decisions that they should be allowed to make!
-
Re: 1st, 2nd, .... child of children

29 July 2008 at 9:45am
Hi,
Regarding your technique to Limit the number of Children returned-- how can I do this with Childern OF children?
I am in my NewsHolder template, which in turn contains other NewsHolders (Subject 1, Subject 2, Subject 3, etc.), and I want to simply get the LATEST 5, of that third level. I can get them all, of course, doing a nested <% control Children %> <% control Children %>, but what if I want to limit the number of records returned on the INside loop?? With a date sort?
Thanks in advance,
Garrett -
Re: 1st, 2nd, .... child of children

1 August 2008 at 4:51am
Hi,
I need a technique to limit the number of Children returned from a certain object-- how can I do this with childern OF children?
I am in my NewsHolder template, which in turn contains other NewsHolders (Subject 1, Subject 2, Subject 3, etc.), and I want to simply get the LATEST 5, of that third level (the actuial news items INSIDE Subject 1, Subject 2, etc.). I can get them all, of course, doing a nested <% control Children %> <% control Children %>, but what if I want to limit the number of records returned on the INNER loop?? With a date sort?
How can this be achieved?
Thanks in advance,
Garrett
| 2828 Views | ||
|
Page:
1
|
Go to Top |



