On Tue, 6 Mar 2001 00:48:00 -0300 Alex Verstraeten <alex@quad.com.ar> wrote:
I'm trying to port a very small portion of a php script i used to have. the concept is quite easy, but I dont see how to accomplish it at zope.
let' see if anyone can understand this php code and tell me which function at zope may I use for it:
print "<table>"; print "<tr>"; while ($item = current($array)) { for ($n=0 ;$n<3;$n++) { print "<td>$item</td>"; next($array); } print "</tr>"; } print "</table>";
what this code does is to print all the contents of an array in a table of 3 columns, using a cell for each element. I'm trying to do this same thing but using a <dtml-in expr="objectValues('Folder')"> instead of the array.
Can someone provide a dtml sample on how to do this?
I'd do it as a PythonMethod or PythonScript: output = '<table>\n' column = 1 for item in array: if column == 1: output = output + '<tr>\n' output = output + '<td>%s</td>\n' % item if column == max_column: output = output + '</tr>\n' column = 1: else: column = column + 1 output = output + '</table>\n' return output This code is written off the top of my head, so I don't know if it works. I do know that it won't do too well when the number of elements in the array isn't a muliple of max_column; I'll leave that as an exercise for the reader :-) John