[PHPTAL] How do you print a grid with tal:repeat ?

Jonathan Vanasco phptal at 2xlp.com
Tue Feb 20 05:05:56 CET 2007


On Feb 19, 2007, at 11:17 AM, 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?

Instead of using an array in the template, use a function that  
consumes 2 items from the array on each repeat (tr) , then generate  
the tds within it.  you can use a tal:condition="true:" to suppress  
an empty td

Search for iterator or generator in the docs.  I'm not sure if PHPTAL  
supports both patterns, but they'd each do what you want.
It's supported in all TAL implementations , regardless of language

// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      FindMeOn.com - The cure for Multiple Web Personality Disorder
|      Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      RoadSound.com - Tools For Bands, Stuff For Fans
|      Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -





More information about the PHPTAL mailing list