Code Example (in the cgiapp):
# Need to divide into sixths for Rosie's design...
my $count = 0;
my $six_issues = [];
my $rows = [];
while( my $hr = $sth->fetchrow_hashref() ) {
$hr->{'bi_rate'} = sprintf( "%.2f", $hr->{'bi_rate'} );
$count++;
my $img = 'graphics/TOC/' .
sprintf( "%02d", $hr->{'volume_num'} ) .
sprintf( "%02d", $hr->{'issue_num'} ) .
'/cover-small.jpg';
push @$six_issues, {
'image_file' => $img,
'id' => $hr->{'id'},
'label' => $hr->{'label'},
'volume_num' => $hr->{'volume_num'},
'issue_num' => $hr->{'issue_num'},
'bi_rate' => $hr->{'bi_rate'},
};
if ( $count % 6 == 0 ) {
push @$rows, { 'six_issues' => $six_issues };
$six_issues = [];
}
}
push @$rows, { 'six_issues' => $six_issues } if ( $six_issues );
$template->param( 'rows' => $rows );
----------------------
htmltmpl Code Example:
----------------------
<!-- TMPL_LOOP NAME="rows" -->
<tr>
<!-- TMPL_LOOP NAME="six_issues" -->
<td valign="top" nowrap class="sansserif"><label for="ind_<!-- TMPL_VAR NAME="id" -->"><img src="<!-- TMPL_VAR NAME="image_file" -->" border="1" width="92" height="120"></label></td>
<!-- /TMPL_LOOP -->
</tr>
<tr>
<!-- TMPL_LOOP NAME="six_issues" -->
<td valign="top" nowrap class="sansserif"><label for="ind_<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="label" --> <br>
(Vol. <!-- TMPL_VAR NAME="volume_num" -->, Issue <!-- TMPL_VAR NAME="issue_num" -->)<br>
<input type="checkbox" name="ind_issue" id="ind_<!-- TMPL_VAR NAME="id" -->" value="<!-- TMPL_VAR NAME="id" -->">
$ <!-- TMPL_VAR NAME="bi_rate" --> (USD)</label>
</td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
You can see this in action at our FB&C Subscription Website (it's the 2nd process {we don't collect your information from the first step -- it all becomes hidden variables at the bottom of that 2nd page}):
http://www.finebooksmagazine.com/subscribe
This is one of the limitations of HTML::Template, but it's also a bleed or merge of logic/control into the presentation layer. I (& you) might get tempted to move to something like TT, where you can put some logic in the template itself, but that's where you blur the lines of MVC.
I would be interested to read other responses to this, too.
Cheers,
Jason
PS: If you only wanted two, you could workaround it with the __EVEN__ and __ODD__ loop context variables.
------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users