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.

Template Questions /

Nested DataObjectSets control


Reply


2 Posts   599 Views

Avatar
Stevie

Community Member, 4 Posts

8 December 2011 at 6:26pm

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!

Avatar
swaiba

Forum Moderator, 1799 Posts

8 December 2011 at 9:01pm

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