[eluser]Unknown[/eluser]
Hi all,
Here is a little mod to the pagination class so we can have always the same number of (digit) links and keep the size of the pagination div fix. (Just tested for CI 2.0.2)
Also it keeps always the First/Previous/Next/Last links and disable the links in case of first/last page
// file system/libraries/pagination.php
Add a new variable at the top:
Code:
var $fix_page_numbers = 4; // you may want to take this number from the config file
Replace
Code:
$start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
$end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
with
Code:
if($this->fix_page_numbers > $num_pages) {
$this->fix_page_numbers = $num_pages;
}
$start = (($this->cur_page - $this->fix_page_numbers + 1) > 0) ? $this->cur_page - $this->fix_page_numbers + 1 : 1;
$end = $start + ($this->fix_page_numbers - 1);
This
Code:
if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1) )
with
Code:
if ($this->first_link !== FALSE )
This
Code:
$output .= $this->prev_tag_open.'<a >anchor_class.(($this->cur_page != 1) ? 'href="'.$this->base_url.$i:'').'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
with
Code:
$output .= $this->prev_tag_open.(($this->cur_page != 1) ? '<a >anchor_class.'href="'.$this->base_url.$i.'">':'').$this->prev_link.'</a>'.$this->prev_tag_close;
This
Code:
for ($loop = $start -1; $loop <= $end; $loop++)
with
Code:
for ($loop = $start; $loop <= $end; $loop++)
This
Code:
$output .= $this->next_tag_open.'<a >anchor_class.(($this->cur_page < $num_pages) ? 'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix:'').'">'.$this->next_link.'</a>'.$this->next_tag_close;
with
Code:
$output .= $this->next_tag_open.(($this->cur_page < $num_pages) ? '<a >anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">':'').$this->next_link.'</a>'.$this->next_tag_close;
This
Code:
if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages )
with
Code:
if ($this->last_link !== FALSE)
And that's it... not very much for the humanity but it's working and may someone dislike the pagination effect as I do...
And thanks for all the help I have in this forums!