3
You are rushing a bit the things with your template, because there is no link from employees to departments and with your two lists the employee list will be the same and repeated for each department.
You can have only one list in the template, that means that you call your template for each department:
<{departmentname}>
<{foreach item=employee from=$employees}>
<{$employee.name}>
<{/foreach}>
In PHP you call your handler to get all departments eg sorted by name.
Then for each department you call
- the handler for employees and limit by the departmentnummer and order by name.
- assign the departmentname to the template and also the employees and show it.
Other possibility is to make one list of all the employees with the departmentname added (combining the getall arrays of the two handlers) and ordered (array sort) by departmentname and employeename.
Your template could then be something like this:
<{assign var=dpt_name value=''}>
<{foreach item=employee from=$employees}>
<{if $employee.departmentname != $dpt_name}>
<{$employee.departmentname}>
<{assign var=dpt_name value=$employee.departmentname}>
<{/if}>
<{$employee.name}>
<{/foreach}>