» » » » » » Joomla: How to make a pagination like Google

Joomla: How to make a pagination like Google

posted in: Joomla | 0
  • edit the libraries/joomla/html/pagination.php
  • In the function __construct see the line $displayedPages = 10;
  • Replace the $this->set( ‘pages.start’,… with the following lines

  $_remainder = $this->get('pages.current') % $displayedPages;
  if($__remainder == 0){
     $this->set( 'pages.start', (floor( $this->get('pages.current') / $displayedPages)) * $displayedPages -4);  
  }elseif($__remainder == 1 and $this->get('pages.current') > $displayedPages){
     $this->set( 'pages.start', (floor( ($this->get('pages.current')-1) / $displayedPages)) * $displayedPages -4);  
  }else{
    $this->set( 'pages.start', (floor( $this->get('pages.current') / $displayedPages)) * $displayedPages + 1);
  }

  • In the function _buildDataObject find the line

for ($i = $this->get('pages.start'); $i <= $stop; $i ++)

  • In this for loop, find the line

if ($i != $this->get('pages.current') || $this->_viewall)

  • Add the elseif statement,

 if ($i != $this->get('pages.current') || $this->_viewall)
 {
   $data->pages[$i]->base = $offset;
   $data->pages[$i]->link = JRoute::_("&limitstart=".$offset);
 }elseif($i == $this->get('pages.current')){
   $data->pages[$i]->text = '' . $i . '';
 }

This example was originally contributed by User:Mahboobkhalid.

Source: joomla.org

Leave a Reply

Your e-mail address will not be published. Required fields are marked *