Hi,
I've run into this problem again and again and again-- I'm controlling a DataObject::get() resultset, and while in that loop I need to get an ID each time and pass that into another function to get some data from an associated table to get some other stuff. Why can I not do this?
function Clients($limit=5) {
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
if($limit==5)
return DataObject::get("ClientPage", "", 'Sort ASC', "", "$start,$limit");
else
return DataObject::get("ClientPage", "", 'Sort ASC', "", $limit);
}
In the template:
<% control Clients %>
<li>
<% if ClientLogo %>$ClientLogo.SetWidth(100)<% end_if %>
<% if ClientURL %><a href="$ClientURL" target="_blank"><% end_if %><h4>$ClientName</h4><% if ClientURL %></a><% end_if %>
<% if ClientHeadline %><h6>$ClientHeadline</h6><% end_if %>
<% control Testimonials(ClientID) %>
Blah blah blah
<% end_control %>
</li>
<% end_control %>
This is on a Holder page. I need to display all the properties of the child pages, PLUS several rows of other data that BELONG to each of these pages that is stored in another table (using DataObjectManager). How else am I going to do this without knowing what ID I'm on in the loop? I can't put the Clients() function in the ClientPage class because I need to control it on the Holder page.
Any advice on this would help a lot, because I have run into this issue on more than once occasion.
Thanks,
Garrett