Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Getting just 1 child to Display

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

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

Page: 1
Go to End
Author Topic: 1578 Views
  • corkg
    Avatar
    Community Member
    30 Posts

    Getting just 1 child to Display Link to this post

    Hw can i get just the latest child to display?

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

    So just C3 would be displayed in the Parent?

    Thanks

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: Getting just 1 child to Display Link to this post

    <% 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 %>

  • corkg
    Avatar
    Community Member
    30 Posts

    Re: Getting just 1 child to Display Link to this post

    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>

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: Getting just 1 child to Display Link to this post

    I was close =p

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Getting just 1 child to Display Link to this post

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

    1578 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.