Re: AW: [SMARTY] Paging
| From: | Travis Low | Date: | Thu, 12 Dec 2002 13:59:11 +0000 |
| Subject: | Re: AW: [SMARTY] Paging | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6760@lists.php.net to get a copy of this message | ||
What I do is:
- From the HTML form, submit a pagetop and pagesize to the application
- In the application, use the pagetop and pagesize to limit the DB select ("select foo from bar limit pagetop,pagesize")
- Assign the pagetop and pagesize to the template (actual pagesize may differ from requested pagesize depending on number of records)
- In the main template, set up some variables to use in the "next" and "prev" URLs, then include the paging template (which uses those variables) and capture its output
- In the footer template, output the captured pagebar
Also, the pagesize is specified in an ini file that can be edited from the admin section of the application. Neither the designer nor the programmer needs to touch it.
cheers,
Travis
Rasmus Schultz wrote:
I'm not starting an argument, I'm just telling you what I'd do :) If I wanted to expose the number of items per page to the designer, I would do so specifically, not generally with a plugin. Of course it all depends on who you're working with etc. :) --- At 2002-12-12, 12:43:00, Ben Phillips <ben@inchima.com> wrote:-- Travis Low <mailto:travis@dawnstar.org> <http://dawnstar.org/travis>I made a similar plugin a while back ... it's highly impractical, because you're putting SQL statements in Smarty templates - the layout templates get "polluted" with functionality, which means you expose this functionality to the designer. Also, by performing the SQL query inside the template, you make it impractical to perform any additional post-query PHP-processing on the query-result.the query isn't exposed in the template. it can be, or it can be set in the php code so that the template designer simply calls the plugin with the query variable. the query is often never seen by the designer.Functionality like paging doesn't really belong in a Smarty plugin, for a template designer to use - because most template designers don't know how to; it belongs in a PHP library, where the programmer can use it.i have to disagree with this. the designer may or may not wish to use paging, depending on the type of page they are designing. they will also wish to position the results from the query as well as the navigation string wherever they like. they may also want to alter the text for the navigation string, and how it is displayed - options that should be made available for them when they are designing the template. these options are set by the designer, not the php programmer and therefore the designer should have access to the functionality. what if they want to display 10 results per page? or 20? that's not up to the php programmer - that's in the realm of the designer. if there is a more elegant way of doing this, then please let me know. benji.