Actually, in the latest version of H::T, there's a built-in __COUNTER__ var in loops if LOOP_CONTEXT_VARS is on. If you're using HTML::Template::Expr you could perform math tests on __COUNTER__ to break items up by column without having to add anything to the perl. Depends on how strictly you're adhering to the separation of data and presentation...though, if you're using H-T-Expr, that probably isn't too terribly great a concern.
Brian McCain PageMasters Internet Group ----- Original Message ----- From: "Kapoor, Nishikant X" <[EMAIL PROTECTED]> To: "H::T (E-mail)" <[EMAIL PROTECTED]> Sent: Thursday, January 16, 2003 11:57 AM Subject: FW: [htmltmpl] how to display data in four columns Chris has suggested a very fine solution. Some of you might find it crossing the presentation line but it seems to be pretty generic in nature. Thanks Nishi > -----Original Message----- > From: Chris Brown [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 16, 2003 1:08 PM > To: Kapoor, Nishikant X > Subject: Re: [htmltmpl] how to display data in four columns > > > I've done this before by setting an extra flag on the nth > column in my > perl code. > > Say if I was building my loop out of a database query > > #.. db stuff here .. > my $count = 0; > my @loop = (); > while($row = $sth->fetchrow_hashref()) { > if($count == $nth_number_here) { > $row->{flag} = 1; > $count = 0; > } > push(@loop,$row); > $count++; > } > > # init template here > $template->param(loop=>\@loop); > > # output ... > > > And then in the template side something very similar to what to had > <tr> > <tmpl_loop name=loop> > <td><tmpl_var name=some_db_field></td> > <tmpl_if name=flag> > </tr><tr> > </tmpl_if> > </tmpl_loop> > </tr> > > Hope that helps. > Chris > > Kapoor, Nishikant X wrote: > > I guess I was not very clear in my question. Here is some > more explanation. > > > > Yes, displaying variables is indeed a function of HTML but > I was hoping to get some suggestions about displaying the > data in four columns. The html code that I use for displaying > data in two columns is: > > > > <tmpl_loop name=eventLoop> > > <td width="50%"> > > <tmpl_var name=eventTitle> > > </td> > > <tmpl_unless __odd__> > > </tr> > > <tr> > > </tmpl_unless> > > </tmpl_loop> <!-- eventLoop --> > > > > Has anyone used similar construct for displaying data in > four (or n for that matter) columns ? > > > > Thanks > > Nishi > > > > -- > Chris Brown > Web Application Developer > Ballistic Web Design > http://ballisticwebdesign.com/ > 903-533-8666 ------------------------------------------------------- This SF.NET email is sponsored by: Thawte.com Understand how to protect your customers personal information by implementing SSL on your Apache Web Server. Click here to get our FREE Thawte Apache Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users ------------------------------------------------------- This SF.NET email is sponsored by: Thawte.com Understand how to protect your customers personal information by implementing SSL on your Apache Web Server. Click here to get our FREE Thawte Apache Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users
