OPTION 1<< First < Previous 7 8 9 10 11 12 13 Next > Last >>
OPTION 2<< First < Previous 1 ... 8 9 10 11 12 ... 20 Next > Last >>
OPTION 3 - similar to Opt 2
Pages: 1 ... 8 9 10 11 12 ... 20
i modded (quick and dirty mod) mine a bit to show the 3 pages before and after the current page.
like this:
OPTION 1<< First < Previous 7 8 9 10 11 12 13 Next > Last >>
if that's close enough....here's the code:
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix) {
$link = ' <a href="'.db('website').$category.'/';
if (!empty($article)) {$link .= $article.'/';}
$prefix = !empty($pagePrefix) ? $pagePrefix : '';
if ($pageNum > 1) {
$goTo = !empty($article) ? $link : '<a href="'.db('website');
if (($pageNum - 1) == 1) {$prev = $goTo.'" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').'</a> ';}
else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').'</a> ';}
$first = $goTo.'" title="'.l('first_page').' '.l('page').'"><< '.l('first_page').'</a>';
}
else {$prev = '< '.l('previous_page'); $first = '<< '.l('first_page');}
if ($pageNum < $maxPage) {
$next = $link.$prefix.($pageNum + 1).'/" title="'.l('page').' '.($pageNum + 1).'">'.l('next_page').' ></a> ';
$last = $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.l('last_page').' >></a> ';
}
else {$next = l('next_page').' > '; $last = l('last_page').' >>';}
//EDITED
echo '<div class="paginator">'.$first.' '.$prev.' ';
$i= 1;
while($i<$pageNum && $i > 0) {
if ($i>$pageNum-(3+1)) {
echo $link.$prefix.$i.'/" title="'.l('page').' '.$i.'">'.$i.'</a> ';
}
$i++;
}
echo " " . $pageNum . " ";
$j = $pageNum+1;
while($j>$pageNum && $j <= $maxPage) {
if ($j <= $pageNum+3) { echo $link.$prefix.$j.'/" title="'.l('page').' '.$j.'">'.$j.'</a> ';}
$j++;
}
echo ''.$next.' '.$last.'</div>';
//EDITED
}
OPTION 2<< First < Previous 1 ... 8 9 10 11 12 ... 20 Next > Last >>
Code:
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix) {
$link = ' <a href="'.db('website').$category.'/';
if (!empty($article)) {$link .= $article.'/';}
$prefix = !empty($pagePrefix) ? $pagePrefix : '';
if ($pageNum > 1) {
$goTo = !empty($article) ? $link : '<a href="'.db('website');
if (($pageNum - 1) == 1) {$prev = $goTo.'" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').'</a> ';}
else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').'</a> ';}
$first = $goTo.'" title="'.l('first_page').' '.l('page').'"><< '.l('first_page').'</a>';
}
else {$prev = '< '.l('previous_page'); $first = '<< '.l('first_page');}
if ($pageNum < $maxPage) {
$next = $link.$prefix.($pageNum + 1).'/" title="'.l('page').' '.($pageNum + 1).'">'.l('next_page').' ></a> ';
$last = $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.l('last_page').' >></a> ';
}
else {$next = l('next_page').' > '; $last = l('last_page').' >>';}
//EDITED
echo '<div class="paginator">'.$first.' '.$prev.' ';
//if ($pageNum > 1) {
if ($pageNum >= 4) {
echo $goTo.'" title="'.l('first_page').' '.l('page').'">1</a> ';
if ($pageNum > 4) {
echo '...';
}
}
$i= 1;
while($i<$pageNum && $i > 0) {
if ($i>$pageNum-(3)) {
echo $link.$prefix.$i.'/" title="'.l('page').' '.$i.'">'.$i.'</a> ';
}
$i++;
}
echo " " . $pageNum . " ";
$j = $pageNum+1;
while($j>$pageNum && $j <= $maxPage) {
if ($j <= $pageNum+2) { echo $link.$prefix.$j.'/" title="'.l('page').' '.$j.'">'.$j.'</a> ';}
$j++;
}
if ($pageNum<=$maxPage-3) {
if ($pageNum<$maxPage-3) { echo '...';}
echo $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.$maxPage.'</a> ';
}
echo ''.$next.' '.$last.'</div>';
//EDITED
}
OPTION 3 - similar to Opt 2
Pages: 1 ... 8 9 10 11 12 ... 20
Code:
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix) {
$link = ' <a href="'.db('website').$category.'/';
if (!empty($article)) {$link .= $article.'/';}
$prefix = !empty($pagePrefix) ? $pagePrefix : '';
if ($pageNum > 1) {
$goTo = !empty($article) ? $link : '<a href="'.db('website');
if (($pageNum - 1) == 1) {$prev = $goTo.'" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').'</a> ';}
else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').'</a> ';}
$first = $goTo.'" title="'.l('first_page').' '.l('page').'"><< '.l('first_page').'</a>';
}
else {$prev = '< '.l('previous_page'); $first = '<< '.l('first_page');}
if ($pageNum < $maxPage) {
$next = $link.$prefix.($pageNum + 1).'/" title="'.l('page').' '.($pageNum + 1).'">'.l('next_page').' ></a> ';
$last = $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.l('last_page').' >></a> ';
}
else {$next = l('next_page').' > '; $last = l('last_page').' >>';}
//EDITED
echo '<div class="paginator">'.l('pages').': ';
if ($pageNum >= 4) {
echo $goTo.'" title="'.l('first_page').' '.l('page').'">1</a> ';
if ($pageNum > 4) {echo '...';}
}
$i= 1;
while($i<$pageNum && $i > 0) {
if ($i>$pageNum-(3)) {
echo $link.$prefix.$i.'/" title="'.l('page').' '.$i.'">'.$i.'</a> ';
}
$i++;
}
echo " " . $pageNum . " ";
$j = $pageNum+1;
while($j>$pageNum && $j <= $maxPage) {
if ($j <= $pageNum+2) { echo $link.$prefix.$j.'/" title="'.l('page').' '.$j.'">'.$j.'</a> ';}
$j++;
}
if ($pageNum<=$maxPage-3) {
if ($pageNum<$maxPage-3) { echo '...';}
echo $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.$maxPage.'</a> ';
}
echo'</div>';
//EDITED
}