4ca07516bb7f7: Difference between revisions
From Joomla! Documentation
CodeExample provided by Mariska |
No edit summary |
||
| Line 1: | Line 1: | ||
<div class='example'> | <div class='example'> | ||
<div class='example-title'><h4> | <div class='example-title'><h4>JPagination on Frontpage</h4></div> | ||
<div class='commentBlock'> | <div class='commentBlock'> | ||
Mariska wrote:
if you want to Jpagination work on front page change Jpagination.php
on this code function _buildDataObject bicause this method use to generate link on front end // add "&limit=".$this->limit to $data->[]->link
function _buildDataObject() { // Initialize variables $data = new stdClass(); $data->all = new JPaginationObject(JText::_('View All')); if (!$this->_viewall) { $data->all->base = '0';$data->all->link = JRoute::_("&limit=".$this->limit."&limitstart="); // <== this} // Set the start and previous data objects $data->start = new JPaginationObject(JText::_('Start')); $data->previous = new JPaginationObject(JText::_('Prev')); if ($this->get('pages.current') > 1) { $page = ($this->get('pages.current') - 2) * $this->limit; $page = $page == 0 ? : $page; //set the empty for removal from route $data->start->base = '0';$data->start->link = JRoute::_("&limit=".$this->limit."&limitstart="); //<== this$data->previous->link = JRoute::_("&limit=".$this->limit."&limitstart=" . $page); //<== this} // Set the next and end data objects $data->next = new JPaginationObject(JText::_('Next')); $data->end = new JPaginationObject(JText::_('End')); if ($this->get('pages.current') < $this->get('pages.total')) { $next = $this->get('pages.current') * $this->limit; $end = ($this->get('pages.total') - 1) * $this->limit; $data->next->base = $next;$data->next->link = JRoute::_("&limit=".$this->limit."&limitstart=" . $next); // <== this$data->end->link = JRoute::_("&limit=".$this->limit."&limitstart=" . $end); // <== this} $data->pages = array(); $stop = $this->get('pages.stop'); for ($i = $this->get('pages.start'); $i <= $stop; $i++) { $offset = ($i - 1) * $this->limit $offset = $offset == 0 ? : $offset; //set the empty for removal from route $data->pages[$i] = new JPaginationObject($i); if ($i != $this->get('pages.current') || $this->_viewall) { $data->pages[$i]->base = $offset;$data->pages[$i]->link = JRoute::_("&limit=".$this->limit."&limitstart=" . $offset); //<== this} } return $data; }