I'm trying to build a site in Silverstripe and so far it has proven to be quite frustrating. Let's just say that if I wrote it from the ground up in plain PHP it would be live now. ;)
I'm having some nested controls that I've sort of got working after lots of headaches but I just can't close the bag on this one. It's probably dead simple, but I haven't managed to find anythjing that can help me. Google certainly isn't my friend in this case.
I have to separate MySQL queries. The first one shows a list of companies and the second one counts the number of products by that company. This is supposed to be output like this:
Company 1 - (2 products)
Company 2 - (2 product)
etc.
The following dummy I set up works like I want it to:
<% control TheCompanies %>
<a href="/companies/$ID/">$CompanyName</a> -
<% control Top.TheCompany(10) %>
($TheNumber products)<br />
<% end_control %>
<% end_control %>
This dummy now shows the name for company and then shows the number of products for company with ID number 10.
Now I of course want the ID number to be relative to the right company ID (not just number 10). So I've tried the following:
<% control Top.TheCompany($ID) %>
and
<% control Top.TheCompany($TheCompanies.ID) %>
But that doesn't work at all. How do I get the $ID from TheCompanies control block into the TheCompany control block?