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.

General Questions /

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

Accessing Pos & EvenOdd of a DataObjectSet that is a parent of the current DataObjectSet


Reply


3 Posts   1111 Views

Avatar
AdamJ

Community Member, 145 Posts

16 February 2010 at 12:48am

So this is the structure I have.

<% control StoreProducts %>
<% if Variants %>
<tr class="$EvenOdd"> // Shows what I want it to
<td><h4>$Title</h4></td>
</tr>
<tr class="<% if totalVariantsForTable == 2 %>last <% end_if %>first $EvenOdd"> // Shows what I want it to
<% control Variants %>
<% if Active %>
<% if First %><% else %>
<tr class="$FirstLast $EvenOdd"> // What do I do here?
<% end_if %>
<td>$Name</td>
</tr>
<% end_if %>
<% end_control %>
<% end_if %>
<% end_control %>

So basically I'm trying to get EvenOdd's that are all the same, so basically the EvenOdd value of the StoreProducts DataObjectSet. How would I access StoreProducts when its inside a control (and a couple if's)?

I thought $Top would be the answer, but not to be. Any thoughts guys?

Avatar
Hamish

Community Member, 712 Posts

16 February 2010 at 5:50am

I had exactly this problem too - and unfortunately it isn't straightforward to solve. There is currently no way to access that parent without breaking the loop, so I came up with a patch for SSViewer that gave you a new <% parent %> tag. See [url]http://open.silverstripe.org/ticket/4751[/url] for info and a patch you can apply.

Avatar
AdamJ

Community Member, 145 Posts

16 February 2010 at 12:21pm

That worked great, thanks Hamish