The question is really simple: Can I use the standard paginator to paginate data that doesn't come from the main database? For example, to paginate an array, a file, or data fetched without using JDatabase?
If it's possible, how can I do this?
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communityThe question is really simple: Can I use the standard paginator to paginate data that doesn't come from the main database? For example, to paginate an array, a file, or data fetched without using JDatabase?
If it's possible, how can I do this?
I think it is posible. althoug I have not done if before.
The pagination uses as parameters the total number of records that in your case is the array count, the limitstart (index where to start), and the page size.
This is an example in one of my models to get the pagination object
function getPagination()
{
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'),$this->getState('limit') );
}
return $this->_pagination;
}
Sustitute $this->getTotal() for array count and so on.
Also, on the function to retrieve the data you should have and equivalent funciotn to this
$rows = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
to get the information from your structure
getItems()
functions I should have something like the $rows = $this->_getList()
call? As far as I understand, returning a subarray of limit
elements starting on limitstart
will be enough, isn't it?