Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Access "Parent" information from within a contol

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: 284 Views
  • Fraser
    Avatar
    Community Member
    46 Posts

    Access "Parent" information from within a contol Link to this post

    I have a gallery page, inside which, I have a control to output photos. However. From within this control, I need to access some information in the "Parent" ie the gallery, not the photos. I thought I could accomplish this using $Parent.xxxx however this doesn't appear to work.

    How can I access this (code below shows the $Parent.xxxx attempt)

    <div id="thumbs" class="navigation">
                <ul class="thumbs noscript">
                   <% control Photos %>
                   <li>
                      <a class="thumb" href="$PaddedImage(990,655).URL" title="$Title">
                         <img src="$Thumbnail(179,119).URL" alt="Title #16" />
                      </a>
                      <div class="caption">
                         <% if Parent.GalleryText %>
                            <div class="image-desc">$Parent.GalleryText</div>
                         <% else %>
                            <div class="image-title">$Title</div>
                            <div class="image-desc">$Description</div>
                         <% end_if %>
                      </div>
                   </li>
                   <% end_control %>
                </ul>
             </div>

  • Fraser
    Avatar
    Community Member
    46 Posts

    Re: Access "Parent" information from within a contol Link to this post

    Solved:

    $Top.xxxxx

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