html-tabletemplate-talphptal

PHPTAL and specific table


I have to create specific table in PHPTAL. I have array like that:

$tab = array('item1', 'item2', 'item3', 'item4');

Final table should be look like that:

<table>
    <tr>
        <td>Item1</td>
        <td>Item2</td>
    </tr>
    <tr>
        <td>Item3</td>
        <td>Item4</td>
    </tr>
</table>

So I was trying use tal:condition width "repeat/item/odd" and "repeat/item/even" to fit < tr > tag in right place, but it not working that I want to.

Have you any ideas?


Solution

  • <tr tal:repeat="row php:array_chunk(tab, 2)">