On 09-09-2009 at 10:10:23 romtek <rom...@gmail.com> wrote:

I have a question on the same topic but with somewhat different details.

<div tal:repeat="item collection">
     <div tal:content="php: someFunction(item.id)></div>

That doesn't work for me. The only way to get what I want is to use
tal:define to define a variable set to item.id and pass it to the function.
Is there a simpler way? Is this a bug?

That works if 'item' is an object and has 'id' property.

If it's an array, null or anything else, you need to adjust syntax accordingly.

You don't need tal:define, but it could help if you're not sure what 'item' contains and want to use TALES magic:

tal:define="itemid item/id" tal:content="php:someFunction(itemid)"

This is because with "item/id" TAL expression PHPTAL inspects object and finds "id" in it regardless of type, and with php: you have to know type and use appropriate syntax (item.id, item['id'], item.id(), etc.).

regards, Kornel

PHPTAL mailing list

Reply via email to