Hello

September 10, 2010, 10:50:10 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
What sNews Is: - sNews is a simple, basic, customizable CMS tool suitable for developers with beginner-to-advanced PHP skills. It is also useful to have a good working knowledge of how to work with, set up and manage MySQL databases. sNews is not - geared towards the end-user who knows little or nothing about building and developing PHP-MySQL based websites.
News: Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: [MOD]Pagination Links Options  (Read 9604 times)
takil84
Newbie
*

Karma: 0
Posts: 49


« on: March 14, 2007, 06:23:23 PM »

SEE MOD IN 2nd POST

Hello guys ,
I have a problem with pagination mod that I found in this mod section.
But this mod pagins all of the pages for instance assume that we have 40 pages.At the bottom of the page the mod shows all of 40 pages.Now , I want the mod shows like this.
last next 1 2 3 .....38 39 40 pre first
Could you please tell me what should I do to make it to show above ?
Regards..
Logged
bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #1 on: March 14, 2007, 09:23:26 PM »

OPTION 1
Quote
<< First < Previous 7 8 9 10 11 12 13 Next > Last >>
OPTION 2
Quote
<< First < Previous 1 ... 8 9 10 11 12 ... 20 Next > Last >>
OPTION 3 - similar to Opt 2
Quote
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
Quote
<< First < Previous 7 8 9 10 11 12 13 Next > Last >>
if that's close enough....here's the code:
Quote
// 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
Quote
<< First < Previous 1 ... 8 9 10 11 12 ... 20 Next > Last >>
Code:
Quote
// 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
Quote
Pages: 1 ... 8 9 10 11 12 ... 20
Code:
Quote
// 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
}
« Last Edit: March 21, 2008, 04:52:51 PM by bakercad » Logged

takil84
Newbie
*

Karma: 0
Posts: 49


« Reply #2 on: March 14, 2007, 10:48:20 PM »

Hi baker;
This code is not what i want exactly.
I want a mod that pagins like this
    << First < Previous 1 2 3 4 . . . . . 38 39 40 Next > Last >>
They are dots between first 4 number and last 4 number.
Assume that we come 4. page it must pagin
    << First < Previous 4 5 6 ....... 38 39 40 Next > Last >>
I dont know if I explain.
BTW Thank you very much for your interest.
Regards.
Logged
takil84
Newbie
*

Karma: 0
Posts: 49


« Reply #3 on: March 14, 2007, 11:13:05 PM »

http://www.bildirgec.org/
This site pagination system is exactly what i want.
Could you please make the code like this ?
I would appreciate if you make this mate.
Logged
piXelatedEmpire
MIA
Thread Moderator
ULTIMATE member
*****

Karma: 37
Posts: 1456


currently MIA


« Reply #4 on: March 15, 2007, 01:39:23 AM »

Quote from: bakercad
i modded (quick and dirty mod) mine a bit to show the 3 pages before and after the current page.
like this:
Quote
<< First < Previous 7 8 9 10 11 12 13 Next > Last >>
GREAT! Cheers baker thats a terrific addition and much needed alteration to the Pagination MOD Cheesy
Logged

my apologies to the sNews crew, but I will be MIA for the forseeable future
bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #5 on: March 15, 2007, 02:46:01 AM »

SEE OPTION 2 IN 2nd POST

and thanks PIX! Wink
Logged

mike1
Full Member
***

Karma: 6
Posts: 205


« Reply #6 on: March 15, 2007, 03:18:57 AM »

cool beans baker
Logged
bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #7 on: March 15, 2007, 02:04:21 PM »

Added Option 3
Quote
Pages: 1 ... 8 9 10 11 12 ... 20
Logged

bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #8 on: March 15, 2007, 02:36:47 PM »

Here's a styling option for Option #3
Looks like:


Edited Paginator Code:
Quote
// 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"><p>'.l('pages').': ';
   if ($pageNum >= 4) {
      echo $goTo.'" title="'.l('first_page').' '.l('page').'" class="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.'"  class="page">'.$i.'</a> ';
        }
        $i++;
    }
    echo ' <span class="pageselected">' . $pageNum . '</span> ';
    $j = $pageNum+1;
    while($j>$pageNum && $j <= $maxPage) {
        if ($j <= $pageNum+2) {    echo $link.$prefix.$j.'/" title="'.l('page').' '.$j.'"  class="page">'.$j.'</a> ';}
        $j++;
    }
    if ($pageNum<=$maxPage-3) {
        if ($pageNum<$maxPage-3) { echo '...';}
      echo $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'" class="page">'.$maxPage.'</a> ';
   }
    echo'</p></div>';
//EDITED
}
Code for CSS file:
Quote
a.page {
   background: #D40000;
   border: 1px solid #D40000;
   padding: 3px 4px;
   color: #fff;
   text-decoration: none;
}
a:hover.page {
   background: #FF9F9F;
   border: 1px solid #D40000;
   padding: 3px 4px;
   color: #000;
   text-decoration: none;
}
.pageselected {
   border: 1px solid #D40000;
   background: #fff;
   padding: 3px 4px;
   color: #D40000;
}
« Last Edit: March 21, 2008, 04:53:23 PM by bakercad » Logged

takil84
Newbie
*

Karma: 0
Posts: 49


« Reply #9 on: March 15, 2007, 08:53:25 PM »

Thank you very much baker you did an impressive mod .
Thank you.
Logged
bakercad
Administrator
ULTIMATE member
******

Karma: 105
Posts: 1654



WWW
« Reply #10 on: March 15, 2007, 08:56:08 PM »

no problem....glad to help  Cheesy
Logged

takil84
Newbie
*

Karma: 0
Posts: 49


« Reply #11 on: March 15, 2007, 09:07:19 PM »

Im also looking forward to releasing date of your multi mod.
You are number one  Cheesy
Logged
Sasha
Hero Member
*****

Karma: 28
Posts: 929



WWW
« Reply #12 on: March 17, 2007, 07:18:21 AM »

This is great MOD.Thanx for this.I got plan to use this mode whit my graphic on my web site.....
Logged

Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥
Patric Ahlqvist
Nobodys perfect, but Im pretty effing close
Administrator
ULTIMATE member
******

Karma: 65
Posts: 4917


“I'm a self-made man and worships my creator.”


WWW
« Reply #13 on: May 06, 2007, 01:47:26 PM »

Aha, and works it does... Likey mucho, Bob. Incorporated this into youknowwhat, and it works wonders...
Logged

My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs
mattonik
Full Member
***

Karma: 6
Posts: 121



WWW
« Reply #14 on: May 06, 2007, 04:17:55 PM »

thanks a lot for this paginator mod Smiley
Logged
Pages: [1] 2
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!