Prev | Current Page 300 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


??? ??? ??? ??? ??? ??? ???
Chapter 8
[ 225 ]
JPagination is used extensively by components in the backend when displaying lists
of items. Normally we add a method called getPagination() to the model, which
deals with the items we are trying to paginate, to get a pagination object. This is an
example of such a method:
/**
* Get a pagination object
*
* @access public
* @return JPagination
*/
function getPagination()
{
if (empty($this->_pagination))
{
// import the pagination library
jimport('joomla.html.pagination');
// prepare the pagination values
$total = $this->getTotal();
$limitstart = $this->getState('limitstart');
$limit = $this->getState('limit');
// create the pagination object
$this->_pagination = new JPagination($total, $limitstart,
$limit);
}
return $this->_pagination;
}
There are three important aspects to this method. We use the attribute _pagination
to cache the object. We use the getTotal() method to determine the total number of
items. We use the getState() method to determine the number of results to display.


Pages:
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
katalog stron wierszyki ogłoszenia dieta light Tango Olsztyn