[PHPTAL] tal:condition question

2011-09-23 Thread Teis Lindemark

Hi,

I have a list in my application where the first column should be one 
icon if the id of the offer is in an array or another icon otherwise. 
The array that have some icons looks something like this: $tmp[id] = 1 or 0.


If id is 1, I should have one icon and another if 0. I added the array 
to template like this: $template-tmp = $tmp; and then I tried to do this:
td tal:condition=tmp/${offers/idiffer}/td Where offers/idoffer 
is the list that is repeated in the table, so each row have one idoffer.


Do anyone have any suggestion how I can fix this?

Hope you understand my problem.

Cheers,

Teis

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] tal:condition question

2011-09-23 Thread Kornel Lesiński

On Fri, 23 Sep 2011 19:16:11 +0100, Teis Lindemark m...@teilin.net wrote:

I have a list in my application where the first column should be one  
icon if the id of the offer is in an array or another icon otherwise.  
The array that have some icons looks something like this: $tmp[id] = 1  
or 0.


If id is 1, I should have one icon and another if 0. I added the array  
to template like this: $template-tmp = $tmp; and then I tried to do  
this:
td tal:condition=tmp/${offers/idiffer}/td Where offers/idoffer  
is the list that is repeated in the table, so each row have one idoffer.


If tmp has items for all IDs, then it should work fine (I presume  
idiffer misspelling is only in the e-mail).


Otherwise you can test for existence with:

tal:condition=exists:tmp/${offers/idoffer}


If you want to toggle between two icons:

td tal:condition=tmp/${offers/idoffer}/td
td tal:condition=not:tmp/${offers/idoffer}/td


--
regards, Kornel Lesiński

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal