and how can I solve this if I want to use it in my tal:repeat?
e.g. for a Client, who has (potentially) multiple "invoices" <tr tal:repeat="client clients"> <td>${client/name}</td> <td><span tal:repeat="invoice client/invoices">${invoice}<tal:block tal:condition="not:repeat/invoice/end">,</tal:block></span></td> </tr> this works fine if I retrieve all invoices before, but can I do it without looping through all clients in PHP first, if I'd have a function getInvoices($client_id)... ? Friday, June 18, 2010, 3:56:23 PM, you wrote: > On 18-06-2010 at 14:46:13 GRolf <ger...@pictureparking.com> wrote: >> let's say I have a query that will fetch employees from a table. every >> row has a field "department_id". >> when looping through this array in my template, is there a way to call a >> "callback" function that will fetch the department's name from an other >> table? > PHPTAL automatically calls methods in TAL expressions. If you use ORM it > should be quite simple, e.g. if you have Employee object that has > getDepartment() method that returns Department object: > <li tal:repeat="employee employees" > tal:content="employee/getDepartment/name"/> > Alternatively you can call PHP functions using php: prefix in expressions: > <li tal:repeat="employee_row employees_array"> > <tal:block tal:define="department > php:get_department_row(employee_row['department_id'])" > tal:content="department/name"/> > -- regards, Kornel _______________________________________________ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal