Jump to:

23355 Posts in 17873 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Pull data from top-most Parent

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

Page: 1
Go to End
Author Topic: 2379 Views
  • Karai
    Avatar
    Community Member
    13 Posts

    Pull data from top-most Parent Link to this post

    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:

  • Karai
    Avatar
    Community Member
    13 Posts

    Re: Pull data from top-most Parent Link to this post

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

  • Karai
    Avatar
    Community Member
    13 Posts

    Re: Pull data from top-most Parent Link to this post

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

  • AlaVive
    Avatar
    Community Member
    42 Posts

    Re: Pull data from top-most Parent Link to this post

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

  • Karai
    Avatar
    Community Member
    13 Posts

    Re: Pull data from top-most Parent Link to this post

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

    2379 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.