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 /

How do I get arround: "you also cannot past a variable into a variable"


Reply


3 Posts   831 Views

Avatar
silk

Community Member, 18 Posts

14 May 2010 at 8:23am

Hello,

I have a page TippToppMatchesPage with

static $has_many = array(
'Matches'=>'TippToppMatch',
);

Each TippToppMatch (DataObject) has

static $has_many = array(
'Tipps' => 'TippToppTipp'
);

TippToppTipp is also a DataObject

On TippToppMatchPage I want to show a list of all matches and the "tipp" (german for guessing/betting on a result) of the current user. Therefore, in the template I'd like to do something like this:

<% control Matches %>
<tr class="match">
<td class="matchDate">$Date</td>
<td class="tipp">Top.$TippOfCurrentUserForm($ID)</td>   
<% end_control %>

Unfortunately, this is not allowed since "you (...) cannot past a variable into a variable"
I have found several posts where others had a similar problem, but there never was a solution other than "you have to find a way around it".
Which way to proceed?
TippToppTipp and TippToppMatch are DataObjects, the only Controller available is TippToppMatchesPage but I don't see how TippToppMatchesPage should be able to "see" which TippForm I want to show without using a parameter.

Any suggestion, tutorial or hint?
Thanks in advance,
Christian

Avatar
Willr

Forum Moderator, 5513 Posts

14 May 2010 at 10:31pm

Well instead of passing an ID to an object you need to have the TippOfCurrentUserForm function on your TippToppMatch object.

<% control Matches %>
<tr class="match">
<td class="matchDate">$Date</td>
<td class="tipp">$TippOfCurrentUserForm</td>
<% end_control %>

Then have the TippOfCurrentUserForm function on the TippToppMatch.

Avatar
silk

Community Member, 18 Posts

14 May 2010 at 11:22pm

I want $TippOfCurrentUserForm to insert a form into the template.

As I understand, I have to put this function into a controller, or at least the form action has to be handled by a controller. Right?
How does TippToppMatch gets to know which controller to use?