HI, I'm having major problems working out how to use this template module, i've read CPAN again & again & again & again, I can't understand it.
It says for access to global vars, use the global vars option with the new(); (as show above) , well I've searched the page and cannot find anywhere it showing this option being used.
does anyone know how to do it?
also I have 3 nested loops in my template, only the first one does anything, i'm assuming it's to do with this globals thing, but maybe that's not it, as I don't understand any of the explanation on CPAN for nested loops can anyone help ?
in the PERL
in the template
hope this makes sense to someone!
1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
It says for access to global vars, use the global vars option with the new(); (as show above) , well I've searched the page and cannot find anywhere it showing this option being used.
does anyone know how to do it?
also I have 3 nested loops in my template, only the first one does anything, i'm assuming it's to do with this globals thing, but maybe that's not it, as I don't understand any of the explanation on CPAN for nested loops can anyone help ?
in the PERL
Code:
# Create Menu Arrays
my (@month_data,@year_data,@stat_data,@curstat);
# Set month index
my $mnth = -1;
# Loop each month
foreach my $month (@months){
$mnth++;
if($month){
# Add Month Menu Option
push @month_data, {month => $mnames[$mnth] };
# Set year index
my $yr = -1;
# Loop Years
foreach my $year (@$month){
if($year){
$yr++;
# Create display year text
my $dispyear = $yr + 2005;
# Add Year Menu Option
push @year_data, {year => $dispyear};
# Loop Statement Array
foreach my $stat(@$year){
foreach my $st ($stat){
if($st){
# Set date
my ($year,$month,$day) = split(/-/,substr($st->{'SDate'},0,10));
# Set html display
my $disp = "$day/$month/$year";
# Build each statement link
push @stat_data, {docid => $st->{'DocID'}, period => $disp};
}
}
}
}
}
}
}
# Add menu arrays to template
$template->param('month' => \@month_data);
$template->param('year' => \@year_data);
$template->param('stat' => \@stat_data);
# Set Current Statement Details
if(@rs){
# Set date
my ($year,$month,$day) = split(/-/,substr($rs[0]->{'SDate'},0,10));
push @curstat, {disp => '$day/$month/$year' , docid => $rs[0]->{'DocID'}};
}
else{push @curstat,{disp => 'N/A' , docid => '0'};}
# Add current stat to template
$template->param('curstat' => \@curstat);
print "Content-type: text/html\n\n";
print $template->output;
in the template
Code:
<div id="menu">
<div><div><div style="display:none;"><ul id="imenus0" style="width:95px; z-index:3;">
<!--tmpl_loop name="month"-->
<li style="width:95px;"><a name="<tmpl_var name='month'>" style="text-decoration:none;"><!--tmpl_var name='month'--></a>
<!--tmpl_loop name="year"-->
test<div><div style="width:65px;top:-18px;left:80px;"><ul style=""><li><a name=""><!--tmpl_var name='year'--></a><div><div style="width:140px;top:-18px;left:50px;"><ul style="">
<!--tmpl_loop name="stat"-->
<li><a name="<tmpl_var name='docid'>" onclick="getAjax('<tmpl_var name='url_to_https'>/commissions3.cgi','FA=VW&requireduser=$user&DOC=<tmpl_var name='docid'>','<tmpl_var name='period'>')">Period Ending <!--tmpl_var name='period'--></a></li>
<!--/tmpl_loop-->
</ul></div></div></li>
<!--/tmpl_loop-->
</ul></div></div>
<!--/tmpl_loop-->
</li></ul><div style=\"clear:left;\"></div></div></div></div>
hope this makes sense to someone!
1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.