Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOVED] Need help liberating the Pagination function  (Read 1999 times)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
[MOVED] Need help liberating the Pagination function
« on: June 24, 2007, 05:11:35 pm »

After thinking about it a while (and seeing it get no responses in the other thread) I decided that maybe this plea for help fits better in this section.

************** ORIGINAL WORDING *************

I need to lure the Pagination function out of center() -- as in turning it into a standalone thing. It should still operate as it does now, but I want to be able to place and style it as I please. The current version is a bit limited in that sense, at least it is to me with my incredibly tiny scripting skills.

The styling bit isn't a problem btw, I can take care of that, so any solution to the problem needs to be free and independent of hard-coded styles.

Anyone that can help me solve this ittsy-bittsy problem will of course earn my everlasting respect and be showered with the most lavish praise I can muster at that time.

Obrigado,
:cool:
Logged

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
[MOVED] Need help liberating the Pagination function
« Reply #1 on: June 24, 2007, 06:05:01 pm »

Well, I've make a test with the next code and it works as expected... if you want to try...
These are the steps to do:
#1:
Locate into center function this:
Quote
if (!empty($currentPage) && ($numrows_articles > $article_limit) && s('display_pagination') == 'on') {
            paginator($categorySEF, $currentPage, $totalPages, '', l('paginator'));
         }
And coment it like:
Quote
/*
if (!empty($currentPage) && ($numrows_articles > $article_limit) && s('display_pagination') == 'on') {
            paginator($categorySEF, $currentPage, $totalPages, '', l('paginator'));
         }
*/
#2:
Add this new function anywhere (I've put it before the JavaScript functions):
Quote
function show_paginator() {
   $article = get_id('article');
   $currentPage = strpos($article, l('paginator')) === 0 ? str_replace(l('paginator'), '', $article) : '';
   $home = l('home_sef'); $categorySEF = get_id('category');
   $categorySEF = empty($categorySEF) ? $home : $categorySEF;
   $use_cat_id = $categorySEF == $home ? 0 : retrieve('id', 'categories', 'seftitle', $categorySEF);
   $query_articles = "SELECT * FROM ".db('prefix')."articles WHERE published = 1 AND SUBSTRING(position, 1, 1) != '2'";
     if (!empty($article) && empty($currentPage)) {$query_articles .= " AND seftitle = '$article'";}
   else if ($categorySEF == $home && s('display_page') <> 0) {$id_page = s('display_page'); $query_articles .= " AND id = '$id_page'";}
        else {
         if (s('display_new_on_home') == 'on') {$query_articles .= $use_cat_id != 0 ? " AND category = $use_cat_id" : '';}
   else {$query_articles .= " AND category = $use_cat_id";}
   $query_articles .= " AND position <> 3 ORDER BY date DESC";
         $result_articles = mysql_query($query_articles);
         $numrows_articles = mysql_num_rows($result_articles);
         if (!$result_articles || !$numrows_articles) {echo $title_not_found; return;}
         else {
            $articleCount = s('article_limit');
            $article_limit = (empty($articleCount) || $articleCount < 1) ? 100 : $articleCount;
            $totalPages = ceil($numrows_articles/$article_limit);
            if (!isset($currentPage) || !is_numeric($currentPage) || $currentPage < 1) {$currentPage = 1;}
            else if ($currentPage > $totalPages) {$currentPage = $totalPages;}
            $query_articles .= " LIMIT ".($currentPage - 1) * $article_limit.", ".$article_limit;
         }
   if (!empty($currentPage) && ($numrows_articles > $article_limit) && s('display_pagination') == 'on') {
      paginator($categorySEF, $currentPage, $totalPages, '', l('paginator'));
   }
}}
#3:
finally, put anywhere that you want, inside of your index.php, this call:
Quote
And this is all... but I'll try to verify if it's possible to 'sanitize' a little more this code... :)
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
[MOVED] Need help liberating the Pagination function
« Reply #2 on: June 24, 2007, 06:37:26 pm »

bramsyuur, you are my new hero! This works exactly as I wanted it to. I will now proceed to plaster my walls with your avatar, demand that our Parliament declares June 24 a national day of Fiesta in your honour and shout your name from every rooftop of the entire nation! Fantastico! Estupendo! Maravelloso! Honom ska vi ha! :lol: :) :cool:

(oh, and as far as I'm concerned this question is thoroughly solved.)
Logged

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
[MOVED] Need help liberating the Pagination function
« Reply #3 on: June 24, 2007, 06:40:16 pm »

hehehe!
When your walls are fully plastered, please, send me a picture!  :lol:  :lol:
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[MOVED] Need help liberating the Pagination function
« Reply #4 on: June 25, 2007, 04:16:00 am »

This is fantastic... a new core component ;)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future