[ZPT] repeat and odd/even question

Geir Bækholt lists at elvix.com
Mon Apr 5 05:10:34 EDT 2004


random,
Monday, April 5, 2004, 2:40:46 AM, you wrote:

> I have a brief question.. I have a tal:repeat running from a db
> query, and i want to stagger the results in two columns, so
> it will look like this:

> data1 .. data2
> data3 .. data4
> data5 .. data6
> data7

the cleanest way would be to write a pythonscript that splits your
result sequence into a list of lists
[[data1,data2],[data3,data4],[data5,data6]]

then you can simply loop the outer list for rows and each inner for
the cells.

<tr tal:repeat="row outer_list">
    <td tal:repeat="cell row">
        Note that spans are not technically allowed outside cells in
        tables...
    </td>
</tr>

suddenly , all is a lot cleaner and the need for logic in your
template is a lot smaller :)


-- 
__________________________________________________________________

 Geir Bækholt    ·   Interaction Engineer   ·    Plone Solutions

 Development · Training · Support · http://www.plonesolutions.com
__________________________________________________________________




More information about the ZPT mailing list