Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Nested DataObjectSets control

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

Page: 1
Go to End
Author Topic: 576 Views
  • StevenMayhew
    Community Member
    4 Posts

    Nested DataObjectSets control Link to this post

    Hi all,

    I'm currently working on a project where I have a large result set which I am putting into the template. Within this, I would like to control another DataObjectSet but need to retrieve information from its parent DataObject and can't get it to work.

    <% control Results %>
    <% control Brand %>
    <% control Businesses %>
    <input type="hidden" title="$Name" link="$Link" deal="$Top.Deal" class="hidden latlng" />
    <% end_control %>
    <% end_control %>
    <% end_control %>

    The problem here is that the "deal" is actually inherited from Brand, but $Top returns the DataObjectSet from Results. Is there a simple way to grab only the immediately preceding DataObject and then be able to get information from it?

    I need to be able to loop through all "Businesses" for each "Brand" and breaking that control early to be able to access the "Deal" text obviously breaks this loop.

    Is the easiest option just to write a function in the controller which returns the correct values for me, or is there a way to do it in the templates?


  • swaiba
    Forum Moderator
    1792 Posts

    Re: Nested DataObjectSets control Link to this post

    Try Parent instead of Top or this thread may be of interest...

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.