iRemix94 has asked for the wisdom of the Perl Monks concerning the following question:
I've got another question about the HTML::Template module. I want to repeat a certain block of HTML-Tags according to a given number. In my case: I want to create a table with X columns. Right now I don't know how to make that simple step possible. I tried a TMPL_LOOP, but in my understanding it needs an array ref, filled with hash refs. So I tried to make a hash array with X entries (X is the amount of columns) and tried to repeat the (td) block for every entry in it. But that doesn't work at all.. Is there an easier way, or do I have to do it like that and just make a mistake?Because I get the following error message:
HTML::Template->output() : fatal error in loop output : HTML::Template + : Attempt to set nonexistent parameter 'schedule_columns' - this par +ameter name doesn't match any declarations in the template file : (die_on_bad_par +ams => 1) at D:/Programme/Perl814/lib/HTML/Template.pm line 3304 at martin3.pl line 121
Here's the TMPL-part:
<TMPL_LOOP NAME=DATA_STRUCTURE> <TMPL_IF NAME=BGCOLOR_CUSTOMER> <tr> <TMPL_ELSE> <tr bgcolor="white"> </TMPL_IF> <th><TMPL_VAR NAME=CUSTOMER></th> <th><TMPL_VAR NAME=DOMAIN></th> <td> <TMPL_IF NAME=EXPORT_VALUE> <table style="Width:100%"> <TMPL_LOOP NAME=SCHEDULE_ROWS> <tr> <TMPL_LOOP NAME=SCHEDULE_COLUMNS> <td><b><TMPL_VAR NAME=SCHEDULE></b></t +d> </TMPL_LOOP> </tr> </TMPL_LOOP> </table> </TMPL_IF> </td> <td> <TMPL_IF NAME=IMPORT_VALUE> <table style="Width:100%"> <TMPL_LOOP NAME=SCHEDULE_ROWS> <tr> <TMPL_LOOP NAME=SCHEDULE_COLUMNS> <td><b><TMPL_VAR NAME=SCHEDULE></b></t +d> </TMPL_LOOP> </tr> </TMPL_LOOP> </table> </td> </TMPL_IF> </tr> </TMPL_LOOP>
Here's the PERL code:
for my $domain (keys %{$bi->{$customer}}) { my %data_structure; my @schedule_rows_loop; my @schedule_columns_loop; $data_structure{CUSTOMER}=$customer; $data_structure{DOMAIN}=$domain; for my $host (keys %{$bi->{$customer}->{$domain}}) { my $schedule = $bi->{$customer}->{$domain}->{$host}->{BACK +UPCFG}->{EXPORT_SCHEDULE_1}->{VALUE}; if (defined $schedule) +## Da nicht alle Kunden / Domainen zurzeit eine EXPORT_SCHEDULE haben { my $import_value=$bi->{$customer}->{$domain}->{$host}- +>{BACKUPCFG}->{IMPORT_ACTIVE_1}->{VALUE}; my $export_value=$bi->{$customer}->{$domain}->{$host}- +>{BACKUPCFG}->{EXPORT_ACTIVE_1}->{VALUE}; my $scheduled_export_days =convert_seconds_days(($bi-> +{$customer}->{$domain}->{$host}->{BACKUPCFG}->{EXPORT_BACKUP_LIFETIME +_SEC_1}->{VALUE})); $data_structure{IMPORT_VALUE}=$import_value; $data_structure{EXPORT_VALUE}=$export_value; my @schedule=split(/,/, $schedule); for my $dif_schedule(@schedule) { my %schedule_rows_data; $schedule_rows_data{SCHEDULE}=$dif_schedule; push (@schedule_rows_loop, \%schedule_rows_data); } for(my $i=0;$i<=$scheduled_export_days;$i++) { my %schedule_columns_data; $schedule_columns_data{SCHEDULE_COLUMNS_COUNT}=1; push (@schedule_columns_loop, \%schedule_columns_d +ata); } } } $data_structure{BGCOLOR_CUSTOMER}=$tr_bgcolor; $data_structure{SCHEDULE_ROWS} = \@schedule_rows_loop; $data_structure{SCHEDULE_COLUMNS} =\@schedule_columns_loop; push (@data_structure_loop, \%data_structure); print Dumper(\@data_structure_loop)."\n"; } } $template->param(DATA_STRUCTURE => \@data_structure_loop);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Template question
by tangent (Parson) on Jul 21, 2015 at 12:59 UTC | |
by iRemix94 (Sexton) on Jul 21, 2015 at 13:16 UTC | |
by tangent (Parson) on Jul 21, 2015 at 13:24 UTC | |
by iRemix94 (Sexton) on Jul 21, 2015 at 13:41 UTC | |
by tangent (Parson) on Jul 21, 2015 at 14:02 UTC | |
by iRemix94 (Sexton) on Jul 21, 2015 at 13:54 UTC | |
by tangent (Parson) on Jul 21, 2015 at 18:45 UTC | |
| |
by poj (Abbot) on Jul 21, 2015 at 19:26 UTC | |
by ww (Archbishop) on Jul 21, 2015 at 18:17 UTC | |
|
Re: HTML::Template question
by 1nickt (Canon) on Jul 21, 2015 at 11:23 UTC | |
by iRemix94 (Sexton) on Jul 21, 2015 at 11:33 UTC | |
by 1nickt (Canon) on Jul 21, 2015 at 11:39 UTC | |
by iRemix94 (Sexton) on Jul 21, 2015 at 11:58 UTC | |
by 1nickt (Canon) on Jul 21, 2015 at 12:08 UTC | |
|