PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Custom scrolling styles

Creating your own scrolling style requires that you implement Zend_Paginator_ScrollingStyle_Interface, which defines a single method, getPages(). Specifically,

<?php
public function getPages(Zend_Paginator $paginator$pageRange null);

This method should calculate a lower and upper bound for page numbers within the range of so-called "local" pages (that is, pages that are nearby the current page).

Unless it extends another scrolling style (see Zend_Paginator_ScrollingStyle_Elastic for an example), your custom scrolling style will inevitably end with something similar to the following line of code:

<?php
return $paginator->getPagesInRange($lowerBound$upperBound);

There's nothing special about this call; it's merely a convenience method to check the validity of the lower and upper bound and return an array of the range to the paginator.

When you're ready to use your new scrolling style, you'll need to tell Zend_Paginator what directory to look in. To do that, do the following:

<?php
$prefix 
'My_Paginator_ScrollingStyle';
$path   'My/Paginator/ScrollingStyle/';
Zend_Paginator::addScrollingStylePrefixPath($prefix$path);

Zend Framework