Jump to content

Recommended Posts

Posted

Hi all,

I made a new mod, called Perfect pagination, i worked alot for this mode

 

Features:

- It recognize what category you are viewing and alters the number of pages.

- Previous Page link disappear if you are on page 1.

- First Page link if you are on page > 1, link disappear if you are on page 1.

- Last Page link disappear if you view the last page.

- Next Page link disappear if you view the last page.

- same goes if you view a category.

- occupy little place on your website.

- easy to install and easy to custom design.

 

Some screenshoots:

 

pagination_1.jpg

 

pagination_2.jpg

 

pagination_3.jpg

 

Install:

 

Open sources/rankings.php and find:

 

$result = $DB->select_limit("SELECT *
                                 FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats
                                 WHERE sites.username = stats.username AND active = 1 {$category_sql}
                                 ORDER BY {$order_by}
                                ", $CONF['num_list'], $start, __FILE__, __LINE__);

 

After add this:

 

// Select count
$result2 = $DB->query("SELECT *
                                 FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats
                                 WHERE sites.username = stats.username {$category_sql}
                                 ORDER BY {$order_by}", __FILE__, __LINE__);

// Pagination
$numrows = mysql_num_rows($result2);
if ($start < $CONF['num_list']) {
$page = "0";
}
else {
$page = $start / $CONF['num_list'];
}
$pagescount = ceil($numrows/$CONF['num_list']);

// Paginare
$txt['nav'] = '';
if ($pagescount > 1) {
   if (($page + 1) > 1) {
$back = (($page - 1) * $CONF['num_list']) + 1;
$txt['nav'] .= ' <a href="index.php?start=1';
                  if(isset($FORM['method'])) { $txt['nav'] .="&method={$ranking_method}"; }
                  if(isset($FORM['cat']) && strlen($FORM['cat']) != "0" ) { $txt['nav'] .= "&cat={$category_escaped}"; }
                  $txt['nav'] .= '" class="border2" title="First"><<</a> ';
$txt['nav'] .= ' <a href="index.php?start='.$back.'';
                  if(isset($FORM['method'])) { $txt['nav'] .="&method={$ranking_method}"; }
                  if(isset($FORM['cat']) && strlen($FORM['cat']) != "0" ) { $txt['nav'] .= "&cat={$category_escaped}"; }
                  $txt['nav'] .= '" class="border2" title="Back"><</a> ';
}
   for ($page_number = 1; $page_number <= $pagescount; $page_number++) {
$start_page = (($page_number - 1) * $CONF['num_list']) + 1;
      if ($page_number == $page) {
         $txt['nav'] .= ' <a href="index.php?start='. $start_page .'';
                  if(isset($FORM['method'])) { $txt['nav'] .="&method={$ranking_method}"; }
                  if(isset($FORM['cat']) && strlen($FORM['cat']) != "0" ) { $txt['nav'] .= "&cat={$category_escaped}"; }
                  $txt['nav'] .= '" class="border3" title="Curent page '. $page_number .'">'. $page_number .'</a> ';
}
       else {
          if ($page_number >= $page - 8 && $page_number <= $page + 8) {
         $txt['nav'] .= ' <a href="index.php?start='. $start_page .'';
                  if(isset($FORM['method'])) { $txt['nav'] .="&method={$ranking_method}"; }
                  if(isset($FORM['cat']) && strlen($FORM['cat']) != "0" ) { $txt['nav'] .= "&cat={$category_escaped}"; }
                  $txt['nav'] .= '" class="border2" title="Page '. $page_number .'">'. $page_number .'</a> ';
}
         else {
            if ($page_number > $page && $dots_after != true) {
               $txt['nav'] .= ' ...';
               $dots_after = true;
            } elseif ($page_number < $page && $dots_before != true) {
               $txt['nav'] .= ' ...';
               $dots_before = true;
            }
         }
      }
   }
   if (($page + 1) < $pagescount) {
$next = (($page+1) * $CONF['num_list']) + 1;
$last = (($pagescount - 1) * $CONF['num_list']) + 1;
         $txt['nav'] .= ' <a href="index.php?start='. $next .'';
                  if(isset($FORM['method'])) { $txt['nav'] .="&method={$ranking_method}"; }
                  if(isset($FORM['cat']) && strlen($FORM['cat']) != "0" ) { $txt['nav'] .= "&cat={$category_escaped}"; }
                  $txt['nav'] .= '" class="border2" title="Next">></a> ';
         $txt['nav'] .= ' <a href="index.php?start='. $last .'';
                  if(isset($FORM['method'])) { $txt['nav'] .="&method={$ranking_method}"; }
                  if(isset($FORM['cat']) && strlen($FORM['cat']) != "0" ) { $txt['nav'] .= "&cat={$category_escaped}"; }
                  $txt['nav'] .= '" class="border2" title="Last">>></a> ';
}
}

$TMPL['pagination'] = $txt['nav'];

 

Save & close.

 

After open skins/YOURSKIN/wrapper.html

 

Place the following anywhere in wrapper.html where you would like to display the Pagination. If you like you can remove center tags, but i think it will look nicer with it.

 

<center>{$pagination}</center>

 

Save & close.

 

After open your CSS style file and add this:

 

.border2 {
border: 1px solid #CCCCCC;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
background-color: #fff;
color: #2d2d2d;
padding:1px;
}
.border3 {
border: 1px solid #2d2d2d;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #2d2d2d;
background-color: #efefef;
font-weight: bold;
padding:1px;
}

 

Save & close. Ok that`s all  I am very tired and i hope that i didn`t missing something.

 

Ps: Next week i will make a high quality template.

 

By Me!!!

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...