I've changed the pagination function a little bit to change the default OpenCart behavior, so it won't mention ?page=1 anymore.
Here is the modification (/system/library/pagination.php):
Code: Select all
public function render() {
$total = $this->total;
$page = $this->page;
$limit = $this->limit;
$num_links = $this->num_links;
$num_pages = ceil($total / $limit);
$output = '';
if ($page > 1) {
$output .= ' <a href="' . ereg_replace('[\?|&]page=%s', '', $this->url) . '">' . $this->text_first . '</a>';
if ($page - 1 == 1)
$output .= '<a href="' . ereg_replace('[\?|&]page=%s', '', $this->url) . '">' . $this->text_prev . '</a> ';
else
$output .= '<a href="' . sprintf($this->url, $page - 1) . '">' . $this->text_prev . '</a> ';
}
if ($num_pages > 1) {
if ($num_pages <= $num_links) {
$start = 1;
$end = $num_pages;
} else {
$start = $page - floor($num_links / 2);
$end = $page + floor($num_links / 2);
if ($start < 1) {
$end += abs($start) + 1;
$start = 1;
}
if ($end > $num_pages) {
$start -= ($end - $num_pages);
$end = $num_pages;
}
}
if ($start > 1) {
$output .= ' .... ';
}
for ($i = $start; $i <= $end; $i++) {
if ($page == $i) {
$output .= ' <b>' . $i . '</b> ';
} else {
if ($i == 1)
$output .= ' <a href="' . ereg_replace('[\?|&]page=%s', '', $this->url) . '">' . $i . '</a> ';
else
$output .= ' <a href="' . sprintf($this->url, $i) . '">' . $i . '</a> ';
}
}
if ($end < $num_pages) {
$output .= ' .... ';
}
}
if ($page < $num_pages) {
$output .= ' <a href="' . sprintf($this->url, $page + 1) . '">' . $this->text_next . '</a> <a href="' . sprintf($this->url, $num_pages) . '">' . $this->text_last . '</a> ';
}
return ($output ? '<div class="' . $this->style_links . '">' . $output . '</div>' : '') . '<div class="' . $this->style_results . '">' . sprintf($this->text, ($total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($total - $limit)) ? $total : ((($page - 1) * $limit) + $limit), $total, $num_pages) . '</div>';
}