Re: [Templates] paginator woes and problems

[prev] [thread] [next] [Date index for 2004/05/21]

From: leegold
Subject: Re: [Templates] paginator woes and problems
Date: 17:33 on 21 May 2004
On Fri, 21 May 2004 14:57:56 +0100, "Dave Cross" <dave@xxxx.xxx.xx> said:
> On Fri, May 21, 2004 at 12:39:04AM -0400, leegold wrote:
> > For the past couple of days I have been trying to understand* how to
> > use a paginator in Perl. I am learning template toolkit because it
> > seems a lot of paginator modules use the toolkit. So ie. 20
> > results/page w/back and forward links.
> > 
> > What I need is very simple working code - if only I had the
> > simplist of real working code I could do this - just a working
> > example. I've looked everywhere on the web w/no luck. No working
> > examples on the web(?!)
> > 
> > I would be grateful again for a *simple* real life working example -
> > the data file, the Perl file, the template file - wouldn't that be it?
> 
> Here's a simple example using Template::Plugin::Page (which is just
> a wrapper around Data::Page). We'll use the Datafile plugin to store
> our data.
> 
> numbers.dat
> -----------
> 
> id : name : description
> 1  : one  : number one
> 2  : two  : the second number
> 3  : three : a third number
> 4  : four : number, the fourth
> 5  : five : numero cinco
> 6  : six  : six (not sex)
> 7  : seven : lucky for some
> 8  : eight : ate
> 9  : nine : number nine, number nine
> 
> page.tt
> -------
> 
> [% USE numbers = datafile('numbers.dat') -%]
> [% USE page = Page(numbers.size, 4, currpage) -%]
> Page [% page.current_page %] of [% page.last_page %]
> Entries [% page.first %] to [% page.last %] of [% page.total_entries %]
>  
> [% FOREACH num = page.splice(numbers) -%]
>   [% num.id %] [% num.name | format('%-8s') %] [% num.description %]
> [% END -%]
> 
> The template takes one input variable (currpage). For this simple
> example we can pass that in using tpage. So, for example:
> 

Is this perl code?

> $ tpage --define currpage=2 page.tt
> Page 2 of 3
> Entries 5 to 8 of 9
>  
>   5 five     numero cinco
>   6 six      six (not sex)
>   7 seven    lucky for some
>   8 eight    ate
>  
> $
> 
> Does that help?
> 
> Dave...
Dave,

I am looking for working code. 
That's the crux of the matter.

I assume there would be a .tt file, .pl file,
and a .dat file.

I need the simplist example
of working code. 

There are no examples of *working*
code for a perl paginator anywhere on the web -
I have searched for days.

Could you give the .pl for your example?
Would that do it?

Lee





> 
> -- 
>   Stab a sorry heart
>   With your favourite finger

        -- 
        http://www.fastmail.fm - A fast, anti-spam email service.

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] paginator woes and problems
leegold 04:39 on 21 May 2004

RE: [Templates] paginator woes and problems
Thomas, Mark - BLS CTR 13:30 on 21 May 2004

Re: [Templates] paginator woes and problems
merlyn (Randal L. Schwartz) 18:06 on 21 May 2004

Re: [Templates] paginator woes and problems
Dave Cross 13:57 on 21 May 2004

Re: [Templates] paginator woes and problems
leegold 17:33 on 21 May 2004

Re: [Templates] paginator woes and problems
Dave Cross 18:43 on 21 May 2004

Re: [Templates] paginator - newbie question
Dave Cross 21:19 on 24 May 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52