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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Pull data from top-most Parent


Reply

5 Posts   2431 Views

Avatar
Karai

23 May 2009 at 1:59pm Community Member, 13 Posts

Hey,

I am trying to pull data from the top-most Parent. Right now I can access data from the Parent of the current page, but if I am deeper nested it won't access the page I need, and if I am on the page I need, it won't access the data. D:

Avatar
Karai

23 May 2009 at 3:40pm Community Member, 13 Posts

Hmm, I got it 2/3 working. I can access the direct Parent or if there is no Parent, access the current Page, but Level(3)+ Pages still don't show the content I need.

                  <% if Parent %>
                     <% control Parent %>
                        <% control Carousels %>
                           <li>$Image<span><a href="$URL">$Caption</a></span></li>
                        <% end_control %>
                     <% end_control %>
                  <% else %>
                     <% control Carousels %>
                        <li>$Image<span><a href="$URL">$Caption</a></span></li>
                     <% end_control %>
                  <% end_if %>

Avatar
Karai

23 May 2009 at 3:42pm Community Member, 13 Posts

^-- DISREGARD THAT --^

This just dawned on me as I was making the previous post, and it works:

<% control Level(1) %>
   <% control Carousels %>
      <li>$Image<span><a href="$URL">$Caption</a></span></li>
   <% end_control %>
<% end_control %>

Avatar
AlaVive

19 September 2009 at 8:20am Community Member, 42 Posts

Thank you for following this through in the forum. You just helped me through a bit of a trouble spot!

Avatar
Karai

19 September 2009 at 8:55am Community Member, 13 Posts

Not a problem! I only wish more people would do so, that way everyone would have their answers. :)