[ZPT] Re: tal:repeat problem
    Tonico Strasser 
    contact_tonico at yahoo.de
       
    Fri May 28 06:05:52 EDT 2004
    
    
  
Nguyen, Joe wrote:
> Let’s say I have a list that I pass to a zpt.  I’ll call this  nameList, 
> with lets say there are 1000+ names on the list.
> 
> I want to display this within a table with only 12 columns. This is 
> where my problem lies.  I’m sure there’s an easy way but I couldn’t quit 
> figure it out!  I have something like this but it doesn’t work at all, 
> just to give you an idea
> 
Not sure what you mean, maybe you want something like this:
<table tal:define="items python: 1000;
                    cols python: 12;
                    remainder python: items % cols;
                    rows python: items / cols;
                    rows python: test(remainder, rows + 1, rows);">
   <tr tal:repeat="row python: range(rows);">
     <td tal:define="start python: cols * row;
                     end python: start + cols;"
         tal:repeat="item python: range(start, end);"
         tal:content="python: test(item <= items, item, 'x');"/>
   </tr>
</table>
> Also, is there a function that can tell if it’s at the end of the list?
Yes, see the ZPT help in the ZMI or the Zope book.
Tonico
    
    
More information about the ZPT
mailing list