On Fri, 21 May 2004 14:57:56 +0100, "Dave Cross" <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
