Forgot -- Re: [PHPTAL] How do you print a grid with tal:repeat ?
Taylor Dondich
tdondich at groundworkopensource.com
Tue Feb 20 01:54:28 CET 2007
That is pretty crazy, as it requires the php modifier. Is this truly
the most elegant way of doing this with PHPTAL? If so, I'll take it.
Just wanted to see if any others had any ideas?
Taylor
Levi Stanley wrote:
> Forgot to think of the case of not even array, so fixed it in this
> version Take a look at the xhtml:
>
> <html>
> <head>
> </head>
> <body>
> <table id='name'>
> <tr tal:repeat="row php: range(0,(ceil(count(items)/2))-1)" >
> <td tal:repeat="col php: range(0,1)">
> <span tal:define="global x php: row*2 + col"
> tal:condition="exists: items/${x}" tal:replace="items/${x}" />
> <span tal:condition="not: exists: items/${x}"
> > </span>
> </td>
> </tr>
> </table>
> </body>
> </html>
>
>
> I added the span with the   in it. And I changed the row to use
> the ceiling fuction so you won't be missing a row.
> Taylor Dondich wrote:
>> Suppose I have 13 items in my collection, and I want to print a table
>> with 2 columns and as many rows as needed for my collection. How do
>> I do that? And if the last row only has one item, how do I know to
>> print the empty td element?
>>
>> Anyone have any ideas or best practices for this?
>>
>> Taylor
>>
>> _______________________________________________
>> PHPTAL mailing list
>> PHPTAL at lists.motion-twin.com
>> http://lists.motion-twin.com/mailman/listinfo/phptal
>>
>> !DSPAM:1,45d9d508248767836945438!
>>
>
More information about the PHPTAL
mailing list