Jump to content

Archived

This topic is now archived and is closed to further replies.

ThLoser

Paging Show only 5 sites?

Recommended Posts

I have a paging script right now, and i want to only show 5 sites like this

 

1 2 3 4 5

2 3 4 5 6

And so on.

 

 

I have 9 pages right now, and when i come to page 6-7 the script removes everything backward but i want it to be 5 6 7 8 9

function pager($link, $page, $pages, $sub='') {
 
   $PageLink = '<div class="pagination pagination-mini"><ul>';
 
   if($page != 1) $PageLink .= '<li><a href="'.$link.'&page='.($page-1).'" rel="nofollow">«</a></li>';
 
   if($page+4 >= $pages) $pagex=$pages;
   else $pagex = (($page != 5) ? $page+4 : $page+1);
   echo $page-4;
   for($i=$page-4 ; $i<=$pagex ; $i++) {
      if($i<=0) $i=1;
      if($i==$page) $PageLink .= '<li><a href="#" style="font-weight:bold;" rel="nofollow">'.$i.'</a></li>';
      else $PageLink .= '<li><a href="'.$link.'&page='.$i.'" rel="nofollow">'.$i.'</a></li>';
   }
 
   if($page != $pages) $PageLink .= '<li><a href="'.$link.'&'.$sub.'page='.($page+1).'" rel="nofollow">»</a></li>';
 
   $PageLink .= '</div>';
 
   return $PageLink;
}

I can try to explain better if necessary

Share this post


Link to post
Share on other sites

he

in your code try to replace

   if($page+4 >= $pages) $pagex=$pages;
   else $pagex = (($page != 5) ? $page+4 : $page+1);
   echo $page-4;
   for($i=$page-4 ; $i<=$pagex ; $i++) {

with

   if($page+2 >= $pages) $pagex=$pages; else $pagex = $page+2);
   if($page > $pagex - 2) $pagein = $pagex - 4; else $pagein = $page - 2;
   if($pagein < 1) $pagein = 1;
   for($i = $pagein; $i <= $pagex; $i++) {

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.