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.

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.

Archive /

Our old forums are still available as a read-only archive.

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

Getting just 1 child to Display


Go to End


5 Posts   2154 Views

Avatar
corkg

Community Member, 30 Posts

28 August 2008 at 9:22pm

Hw can i get just the latest child to display?

->Parent
----->C3
----->C2
----->C1

So just C3 would be displayed in the Parent?

Thanks

Avatar
grilldan

Community Member, 135 Posts

28 August 2008 at 9:50pm

<% if First %>
<ul>
<% control Children %>
<li><a href="$Link" title="Go to the $Title.XML page" id="$LinkingMode">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>

Avatar
corkg

Community Member, 30 Posts

28 August 2008 at 9:54pm

Thanks had to change it to make it work by moving the if First:

<ul>
<% control Children %>
<% if First %>
<li><a href="$Link" title="Go to the $Title.XML page" id="$LinkingMode">$MenuTitle</a></li>
<% end_if %>
<% end_control %>
</ul>

Avatar
grilldan

Community Member, 135 Posts

28 August 2008 at 9:56pm

I was close =p

Avatar
Sean

Forum Moderator, 922 Posts

28 August 2008 at 10:07pm

I wonder if you could make that even shorter by using <% control Children.First %> ?