RE: [SMARTY] Paging a database result set
| From: | Josh Johnson | Date: | Wed, 23 Oct 2002 16:36:15 +0000 |
| Subject: | RE: [SMARTY] Paging a database result set | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6219@lists.php.net to get a copy of this message | ||
There definitely isn't a built-in function to paginate results, but it's
pretty simple thing to do:
Normally you would pass the page your on and how many per page to show
in a query string: yourfile.html?page=2&per_page=30
You could use those settings inside of the php that instantiates the
smarty object to retrieve only the newsletters the user wants to see,
then assign the results to a template variable, and loop through it
using foreach or section to display the results.
You could also write a plugin function to handle it, and just make one
call to that function within your template.
-- Josh
-----Original Message-----
From: benji [mailto:smarty@benji.f2o.org]
Sent: Wednesday, October 23, 2002 12:04 PM
To: smarty-general@lists.php.net
Subject: [SMARTY] Paging a database result set
i am starting to use smarty to design some smaller sites in order to get
a
feel for how it works.
before i begin, is there an easy way of paging a set of results? for
example, a list of 300 newsletters needs to be shown, but we want to
show 20
at a time with NEXT > and < PREV buttons at the bottom.
i can code this in php, but was wondering if there was a simple way of
providing the option in the template.
cheers,
benji.
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php