Adds ellipses to pagination
parent
eb8104595e
commit
9c187c9550
|
@ -15,6 +15,10 @@
|
||||||
if (isset($_REQUEST['event'])) {
|
if (isset($_REQUEST['event'])) {
|
||||||
$param .= '&event=' . $_REQUEST['event'];
|
$param .= '&event=' . $_REQUEST['event'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$max_visible_pages = 10;
|
||||||
|
$step_pages = 10;
|
||||||
|
|
||||||
if ($browse_page > 1) {
|
if ($browse_page > 1) {
|
||||||
echo '<span><a href="' . $url . '&p=1">first</a></span>';
|
echo '<span><a href="' . $url . '&p=1">first</a></span>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,21 +26,42 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 1; $i <= $page_count; $i++) {
|
for ($i = 1; $i <= $page_count; $i++) {
|
||||||
if ($i === $browse_page) {
|
// always show the first, last, step pages (10, 20, 30, etc.),
|
||||||
if ($browse_page > 1) {
|
// and the pages close to the current one
|
||||||
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($browse_page -1) . '"><<</a></span>';
|
if (
|
||||||
} else {
|
$i === 1 || // first page
|
||||||
echo '<span><<</span>';
|
$i === $page_count || // last page
|
||||||
}
|
$i === $browse_page || // current page
|
||||||
|
$i === $browse_page -1 ||
|
||||||
|
$i === $browse_page +1 ||
|
||||||
|
$i === $browse_page -2 ||
|
||||||
|
$i === $browse_page +2 ||
|
||||||
|
($i % $step_pages === 0 && $i > $max_visible_pages) // the step pages - 10, 20, etc.
|
||||||
|
) {
|
||||||
|
if ($i === $browse_page) {
|
||||||
|
// current page, no link
|
||||||
|
if ($browse_page > 1) {
|
||||||
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($browse_page -1) . '"><<</a></span>';
|
||||||
|
} else {
|
||||||
|
echo '<span><<</span>';
|
||||||
|
}
|
||||||
|
echo '[' . $i . ']';
|
||||||
|
|
||||||
echo '[' . $i . ']';
|
if ($browse_page < $page_count) {
|
||||||
if ($browse_page < $page_count) {
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($browse_page +1) . '">>></a></span>';
|
||||||
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($browse_page +1) . '">>></a></span>';
|
} else {
|
||||||
|
echo '<span>>></span>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
echo '<span>>></span>';
|
// other pages
|
||||||
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . $i . '">[' . $i . ']</a></span>';
|
||||||
}
|
}
|
||||||
} else {
|
// show ellipses between distant pages
|
||||||
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . $i . '">[' . $i . ']</a></span>';
|
} elseif (
|
||||||
|
$i === $browse_page -3 ||
|
||||||
|
$i === $browse_page +3
|
||||||
|
) {
|
||||||
|
echo '<span>...</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue