Re: [htmltmpl] TMPL_LOOP limit or count
Brought to you by:
samtregar
|
From: David A. B. <dav...@gm...> - 2011-04-30 01:04:15
|
On Fri, Apr 29, 2011 at 16:37, Michael Peters <mp...@pl...> wrote:
> On 04/29/2011 05:28 PM, David A. Bandel wrote:
>
>> my @calloutdata;
>> foreach $callskey ( sort {$callnum{$b}<=> $callnum{$a}} keys %callnum){
>> my %outbound;
>> $outbound{EXTENNUMCALLED} = $callskey;
>> $outbound{TIMESCALLED} = $callnum{$callskey};
>> push( @calloutdata, \%outbound );
>> }
>>
>> $template->param( OUTBOUNDS => \@calloutdata );
>>
>> The calloutdata array winds up to be about 200 lines long. Any way to
>> have the TMPL_LOOP stop output after 15 or so table lines?
>
> Well, the first thing I'd do is suggest that if possible you just don't put
> all 200 things into the loop. That would save on your processing if you
> didn't have to create the big loop to begin with.
Unfortunately, in order to do what I'm doing (you haven't seen the
code that comes before), I need all the values all at once or the sort
on the value of the key/value pair doesn't work.
>
> But if you needed them in the loop in some places but didn't want to display
> them in others, you can use the __counter__ loop context var combined with
> HTML::Template::Expr.
It's an idea. But hoping to keep it simple.
>
> <tmpl_loop outbounds>
> <tmpl_if expr="__counter__ <= 15">
> ...
> </tmpl_if>
> </tmpl_loop>
>
>> Nothing in the docs suggests a way to do this (or am I missing
>> something?).
>
> It's not possible with just HTML::Template, but HTML::Template::Expr should
> help you get there.
>
> --
> Michael Peters
> Plus Three, LP
>
Will keep this in mind.
Thanx,
David A. Bandel
--
Focus on the dream, not the competition.
- Nemesis Air Racing Team motto
Visit my web page at: http://david.bandel.us/
|