Jump to:

3401 Posts in 979 Topics by 855 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: 521 Views
  • StevenMayhew
    Avatar
    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?

    Cheers!

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Nested DataObjectSets control Link to this post

    Try Parent instead of Top or this thread may be of interest...
    http://www.silverstripe.org/template-questions/show/13619

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