Re: Pager question - can you configure it to page-link alphabetically by last name?
| From: | Lorenzo Alberton | Date: | Wed, 30 Nov 2005 22:19:04 +0000 |
| Subject: | Re: Pager question - can you configure it to page-link alphabetically by last name? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22110@lists.php.net to get a copy of this message | ||
l Burnerheimerton wrote:
For example, give an initial list then the links would be like: A B C D E ... When you clicked on "A", it displayed the first page of people with the last name starting with "A". Can this be done? If so, any examples?You can't do it with Pager, i.e. Pager can split the results only by the number of items, not by the value of their contents. As Massimiliano suggested, if you have a really long list, then paginating the results within each letter may make sense: A [1, 2, 3], B, C [1, 2, 3, 4], ... where you have one pager object for each letter. Please search the ml archives, this question already popped up in the past, IIRC I also posted some actual code. For instance, you could do something like: $pagers = array(); foreach ($letters as $letter) {
//fetch the items starting with $letter
//and pass them to a new Pager object,
//or use the Pager Wrapper if you are fetching
//the items from a db
$pagers[$letter] =& Pager::factory(...);
}
and in the template:
foreach ($pagers as $letter => $pager) {
echo ' '.$letter.' ['.$pager->links.']';} HTH Regards, -- Lorenzo Alberton http://pear.php.net/user/quipo