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

Reply via email to