Re: [htmltmpl] Coding up a three column table...
Brought to you by:
samtregar
From: Roger B. W. <ro...@fi...> - 2004-05-12 09:20:11
|
On Wed, May 12, 2004 at 10:05:03AM +0100, Dave Hodgkinson wrote: >I've got an image gallery that I want displayed as three columns. >Am I right in assuming that I need to code it up as an array of rows >containing the array of the column cells? No, but that's one way to do it. Another, and what I'd do if I were feeling lazy, would be to use a single level of loop with extensions, something like: <table> <tmpl_loop name=stuff> <tmpl_if name=colstart> <tr> </tmpl_if> <td>your_content_here</td> <tmpl_if name=colend> </tr> </tmpl_if> </tmpl_loop> </table> and just poke colstart and colend in the right place. >Anyone got any nice idiomatic perl for transforming a simple array >into one of these? ;-) # generate @content with the image names and so on for (my $n=0;$n<=$#content;$n+=3) { $content[$n]{colstart}=1; } for (my $n=2;$n<=$#content;$n+=3) { $content[$n]{colend}=1; } $content[-1]{colend}=1; (warning, totally untested, but it probably works) Roger |