21282 Posts in 5730 Topics by 2601 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 968 Views |
-
Questions: Print Level Number, Child of Children...

4 December 2009 at 12:43am Last edited: 4 December 2009 11:04am
Hi,
1) How can I print "Level" number or actual deep?
2) I'm into a page with at X. Then I need info from of object from first child of each childreon of page at level X ...
Page Level X / Children / 1st Child
Thank you
-
Re: Questions: Print Level Number, Child of Children...

4 December 2009 at 11:54am
You can just do manual counts if it would be more efficient, here is an example for use in a controller function (ie control):
$item = $this->dataRecord;
$level = 0;
// 10 is just a limit to prevent endless loops, increase as needed
while($item && $level < 10) {
$item = $item->Parent;
$level++;
} -
Re: Questions: Print Level Number, Child of Children...

4 December 2009 at 7:48pm
thank for your reply. This in an answer for point 1). And for 2)?
-
Re: Questions: Print Level Number, Child of Children...

5 December 2009 at 4:04am
Ah, sorry about that. Silverstripe's Hierarchy provides this:
Model:
$firstChild = $this->Children()->First();Controller:
$firstChild = $this->dataRecord->Children()->First(); -
Re: Questions: Print Level Number, Child of Children...

16 December 2009 at 4:49am Last edited: 16 December 2009 4:49am
Hi,
I resolved question 2 with:
<% control Children %>
<% control Children %>
<% if First %>
<div class="fright-imm-prod-table alignright">
<a href="$Link" >$Image1.Thumbnail</a>
</div>
<% end_if %>
<% end_control %>
<% end_control %>Bye
| 968 Views | ||
|
Page:
1
|
Go to Top |

