Re: AW: [SMARTY] Paging
| From: | Richard Watt | Date: | Thu, 12 Dec 2002 10:50:02 +0000 |
| Subject: | Re: AW: [SMARTY] Paging | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6745@lists.php.net to get a copy of this message | ||
I already have the capability to put LIMIT statements in, although I
havent implemented that while im in the middle of testing, the issue im
working on at the moment is the efficiency of the paging code,
specifically;
{capture name=maxrecords}{math equation="x + y" x=
$smarty.get.offset|default:0 y=#recordsPerPage#}{/capture}
{capture name=lastpage}{math equation="x - y" x=$records
y=#recordsPerPage#}{/capture}
Viewing records {math equation="x + 1" x=
$smarty.get.offset|default:0}-{if $records gte
$smarty.capture.maxrecords}{$smarty.capture.maxrecords}{else}{$records}
{/if} of {$records}
<BR>
{if $smarty.get.offset <> 0}<a href="./admin.php?p=style&offset=0">
<<</a>{/if}
{if $smarty.get.offset <> 0}<a href="./admin.php?p=style&offset=
{math equation="x - y" x=$smarty.get.offset|default:0
y=#recordsPerPage#}"><</a>{/if}
{if $smarty.get.offset < $smarty.capture.lastpage}<a
href="./admin.php?p=style&offset={math equation="x + y" x=
$smarty.get.offset|default:0 y=#recordsPerPage#}">></a>{/if}
{if $smarty.get.offset < $smarty.capture.lastpage}<a
href="./admin.php?p=style&offset={$smarty.capture.lastpage}">>></a>{/if}
Which generates
'Viewing records 6-12 of 403'
'<<first page <previous page | next page> last page>>'
type text & navigation links
In article <B3E252A41984D411BF68009027E5CE97056424B1@exchange-
ms01.pironet-ndh.com>, mdeutschmann@pironet-ndh.com says...
> what about doin' this in the (my)sql select?
>
> greets
> mario
>
>
> > -----Ursprungliche Nachricht-----
> > Von: Richard Watt [mailto:richard@rwatt.co.uk]
> > Gesendet: Donnerstag, 12. Dezember 2002 11:11
> > An: smarty-general@lists.php.net
> > Betreff: [SMARTY] Paging
> >
> >
> > Ignore that last thread about errors, I managed to fix it (I
> > was making
> > calls to a function on one of my classes that messed things up). Next
> > question is regarding paging tables.
> >
> > I have managed to do a multipage output of an array using
> > only smarty,
> > but it makes rather a lot of use of the {math} function,
> > which I realise
> > is not very efficient. Is there any way of doing this more
> > efficiently
> > (I know there is a custom paging function I can download, but I would
> > prefer to do this in Smarty as I need a bit more than that function
> > provides)?
> >
> > {section name=styles loop=$mystyle max=#recordsPerPage# start=
> > $smarty.get.offset|default:0}
> > {if $smarty.section.styles.first}
> >
> > <table class="table_content">
> > <tr>
> > <th>
> > Name
> > </th>
> > <th>
> > Directory
> > </th>
> > <th>
> > Description
> > </th>
> > </tr>
> > {/if}
> > <tr>
> > <td class="{cycle values="rowlight,rowdark" advance=false}">
> >
> > {$mystyle[styles].styleName}
> > </td>
> > <td class="{cycle advance=false}">