Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2

Author Topic: [MOD] Pagination mod (sNews 1.5)  (Read 18196 times)

scienceofsleep

  • Guest
[MOD] Pagination mod (sNews 1.5)
« on: October 17, 2006, 09:18:38 pm »

I LOVE the pagination feature, If you prefer the pages to be split and allow you to select the pages individually then here is a small mod.

find this:
Code: [Select]
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix) {
$link = ' if (!empty($article)) {$link .= $article.'/';}
$prefix = !empty($pagePrefix) ? $pagePrefix : '';
if ($pageNum > 1) {
$goTo = !empty($article) ? $link : '
if (($pageNum - 1) == 1) {$prev = $goTo.'" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').' ';}
else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('page').' '.($pageNum - 1).'">< '.l('previous_page').' ';}
$first = $goTo.'" title="'.l('first_page').' '.l('page').'"><< '.l('first_page').'';
    }
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').' > ';
$last = $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.l('last_page').' >> ';
}
else {$next = l('next_page').' > '; $last = l('last_page').' >>';}
echo '
'.$first.' '.$prev.'  ['.$pageNum.' / '.$maxPage.']   '.$next.' '.$last.'
';
}
and rewrite to this
Code: [Select]
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix) {
$link = ' if (!empty($article)) {$link .= $article.'/';}
$prefix = !empty($pagePrefix) ? $pagePrefix : '';
if ($pageNum > 1) {
$goTo = !empty($article) ? $link : '
if (($pageNum - 1) == 1) {$prev = $goTo.'" title="'.l('page').' '.($pageNum - 1).'"> '.l('previous_page').' ';}
else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('page').' '.($pageNum - 1).'"> '.l('previous_page').' ';}
$first = $goTo.'" title="'.l('first_page').' '.l('page').'"><< '.l('first_page').'';
    }
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').' ';
$last = $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.l('last_page').' >> ';
}
else {$next = l('next_page').' '; $last = l('last_page').' >>';}
//EDITED
$i=1;
echo '
'.$first.' '.$prev.' ';
while($i<$maxPage + 1) {
if ($i == $pageNum) {
echo " " . $i . " ";
} else {
echo $link.$prefix.$i.'/" title="'.l('page').' '.$i.'">'.$i.' ';
}
 $i++;
}
 echo ''.$next.' '.$last.'
';
//EDITED
}
I do not have a demo but here is a screenshot
Logged

ketut

  • Full Member
  • ***
  • Karma: 0
  • Posts: 115
    • Book Bali Hotels
[MOD] Pagination mod (sNews 1.5)
« Reply #1 on: October 24, 2006, 04:00:28 am »

nice addon!

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[MOD] Pagination mod (sNews 1.5)
« Reply #2 on: November 09, 2006, 07:04:47 am »

Nice indeed.

Now to place the title of the previous article to the left of the pagination, and the next article to the right.
Just so people know what tey are going to.

Will fiddle arund and post results here, unless you beat me to it.
(am still working on a linkpage addon.)
Logged
Of all the things I have lost, it is my mind that I miss the most.

Harold

  • Full Member
  • ***
  • Karma: 0
  • Posts: 110
    • http://blog.haroldbeukers.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #3 on: November 22, 2006, 12:44:55 pm »

I used this mod :)
and changed the: 'first', 'pre, 'next', 'last''into a button (image)
question: but i cant figure it out how to hover the image (where must de "hover image" be placed in snews.php?) i hope someone can give me a hint  how to hover the image (by using a:hover in Css)
i like to hover this images : with this:

paginator linenumber 55 in snews.php  is changed with:
Code: [Select]
#paginator
$l['first_page'] = '<img src="img_paginator/First.gif" alt="eerste" />';
$l['last_page'] = '<img src="img_paginator/Last.gif" alt="laatste" />';
$l['previous_page'] = '<img src="img_paginator/Prev.gif" alt="vorige" />';
$l['next_page'] = '<img src="img_paginator/Next.gif" alt="volgende" />';
$l['first_page_off'] = '<img src="img_paginator/FirstOff.gif" alt="kan niet verder terug :))" />';
$l['last_page_off'] = '<img src="img_paginator/LastOff.gif" alt="dit was alles:))" />';
$l['previous_page_off'] = '<img src="img_paginator/PrevOff.gif" alt="kan niet verder terug :))" />';
$l['next_page_off'] = '<img src="img_paginator/NextOff.gif" alt="je bent er al:))" />';
(alt text in the code is dry humor in dutch, dont pay attention.) :rolleyes:
update: and this code (linenumber 378-408, its a little change on scienceofsleep's code):

Code: [Select]
// 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('').' '.($pageNum - 1).'"> '.l('previous_page').'</a> ';}
        else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('').' '.($pageNum - 1).'"> '.l('previous_page').'</a> ';}
        $first = $goTo.'" title="'.l('').' '.l('page').'"> '.l('first_page').'</a>';
    }
    else {$prev = ' '.l('previous_page_off'); $first = ' '.l('first_page_off');}
    if ($pageNum < $maxPage) {
        $next = $link.$prefix.($pageNum + 1).'/" title="'.l('').' '.($pageNum + 1).'">'.l('next_page').' </a> ';
        $last = $link.$prefix.$maxPage.'/" title="'.l('').' '.l('page').'">'.l('last_page').' </a> ';
    }
    else {$next = l('next_page_off').' '; $last = l('last_page_off').' ';}
//EDITED
    $i=1;
    echo '<div class="paginator">'.$first.' '.$prev.' ';
    while($i<$maxPage + 1) {
        if ($i == $pageNum) {
            echo " " . $i . " ";
        } else {
            echo $link.$prefix.$i.'/" title="'.l('page').' '.$i.'">'.$i.'</a> ';
        }
      $i++;
    }
      echo ''.$next.' '.$last.'</div>';
//EDITED
}
although it's not perfect :D

Im using snews already voor my administration (keyboard teacher) so, there is a login..
to see the demo:
username: ***** (update:i delete the code :))
password: *****
link: http://www.haroldbeukers.nl/snews/dinsdag/
« Last Edit: September 12, 2007, 11:50:00 pm by Harold »
Logged
E=Fb

tobto

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 71
    • seo service
[MOD] Pagination mod (sNews 1.5)
« Reply #4 on: November 22, 2006, 01:13:03 pm »

Looks good, thanks!
I looked at  your articles and thought over Snews definitely lacks of subcategories  :(
Logged

Harold

  • Full Member
  • ***
  • Karma: 0
  • Posts: 110
    • http://blog.haroldbeukers.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #5 on: November 22, 2006, 01:28:52 pm »

yes, thats why i put the links (articles) at the first place in the categorie instead off subcategories.
i think snews isnt really made for this, how i use it. but it works great for me :)
Logged
E=Fb

brauck

  • Hero Member
  • *****
  • Karma: 18
  • Posts: 556
    • http://www.hbw-webdesign.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #6 on: November 23, 2006, 11:33:53 am »

Harold,

Can't you give the link a css-class? like this?

the button:

CSS
Code: [Select]
.button {
width: 21px;  /* dimensions of the button */
height: 21px;
float: left;
background: url(../images/button.gif) no-repeat 0 0;
margin: 0;
padding: 0;
}
a.button:link, a.button:visited, a.button:active {
background: url(../images/button.gif) no-repeat 0 0;
margin: 0;
padding: 0;
}
a.button:hover {
background: url(../images/button.gif) no-repeat -21px 0;
margin: 0;
padding: 0;
}
XHTML:
Code: [Select]
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

Harold

  • Full Member
  • ***
  • Karma: 0
  • Posts: 110
    • http://blog.haroldbeukers.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #7 on: November 23, 2006, 01:06:10 pm »

one image :) even better..
it remembered me to this: http://home.tiscali.nl/developerscorner/port-hole/porthole-nl.htm
i'll try it out (after work)..
or..i could make from 8 images only 1 image..and position it with Css. :D

i was only looking in snews.php to solve the problem (too long behind the screen  :rolleyes: )
 the link is also  in a div with  a class="paginator". (i dont know how to give the link a class, but that is no longer necessary)
Logged
E=Fb

Harold

  • Full Member
  • ***
  • Karma: 0
  • Posts: 110
    • http://blog.haroldbeukers.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #8 on: November 24, 2006, 10:52:32 am »

I was wrong...soooo wrong ! :|
the link does need a class, because the are different images (first,preview, next, last)
but i dont understand PHP...
am i doing right if i put the class inhere? (example shows only 2 of the 4 classes)


-- // PAGINATOR 7th line --
Code: [Select]
       if (($pageNum - 1) == 1) {$prev = $goTo.'"class="button_1" title="'.l('page').' '.($pageNum - 1).'"> '.l('previous_page').' ';}
        else {$prev = $link.$prefix.($pageNum - 1).'/"class="button_2" title="'.l('page').' '.($pageNum - 1).'"> '.l('previous_page').' ';}
Logged
E=Fb

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] Pagination mod (sNews 1.5)
« Reply #9 on: November 24, 2006, 11:00:42 am »

A dumb remark from me ;) :
If it works it's right :lol:

Sorry for that, couldn't help myself ;) I'll shut up now
Logged
"It's only dead fish that goes with the flow... "
Updated

Harold

  • Full Member
  • ***
  • Karma: 0
  • Posts: 110
    • http://blog.haroldbeukers.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #10 on: November 24, 2006, 11:13:24 am »

Quote from: Patrick
If it works it's right
I don't agree  :D

anyway....it doesnt work perfect...
Logged
E=Fb

brauck

  • Hero Member
  • *****
  • Karma: 18
  • Posts: 556
    • http://www.hbw-webdesign.nl/
[MOD] Pagination mod (sNews 1.5)
« Reply #11 on: November 24, 2006, 03:59:16 pm »

Just try it out and see what happens (the best way to learn)  :)
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

mininovax

  • Newbie
  • *
  • Karma: 1
  • Posts: 44
    • http://www.ondapc.net
[MOD] Pagination mod (sNews 1.5)
« Reply #12 on: November 30, 2006, 02:34:25 pm »

This is the same pagination example, with a small modification. The original did not work with my RC3 ... It paginated, but the previous page always took me to the home....

So, I fixed a few things up, the encoding of a couple of characters, and the ability to paginate correctly in Snews 1.5 RC3

FIND // PAGINATOR

And replace the entire function with:


Code: [Select]
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix) {
    $link = ' $goTo = (!empty($article) || (!empty($category) && $category != s('home_sef'))) ? $link : ' if (($pageNum - 1) == 1) {$prev = $goTo.'" title="'.l('page').' '.($pageNum - 1).'"> '.l('previous_page').' ';}
        else {$prev = $link.$prefix.($pageNum - 1).'/" title="'.l('page').' '.($pageNum - 1).'"> '.l('previous_page').' ';}
        $first = $goTo.'" title="'.l('first_page').' '.l('page').'"><< '.l('first_page').'';
    }
    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').' ';
        $last = $link.$prefix.$maxPage.'/" title="'.l('last_page').' '.l('page').'">'.l('last_page').' >> ';
    }
    else {$next = l('next_page').' '; $last = l('last_page').' >>';}
//EDITED
    $i=1;
    echo '
'.$first.' '.$prev.' ';
    while($i<$maxPage + 1) {
        if ($i == $pageNum) {
            echo " " . $i . " ";
        } else {
            echo $link.$prefix.$i.'/" title="'.l('page').' '.$i.'">'.$i.' ';
        }
      $i++;
    }
      echo ''.$next.' '.$last.'
';
//EDITED
}
Updated code for // PAGINATOR -- date: Dec. 1, 2006
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
[MOD] Pagination mod (sNews 1.5)
« Reply #13 on: November 30, 2006, 04:17:25 pm »

Mininovax - just a suggestion... when you post a mod... then alter the code for that mod... it is better to replace the code with the new code in the original post, with a note saying something like... Updated on (date)... and not have the second post. This eliminates any confusion to anyone who tries to use the mod... they will be able to copy and paste the right script from your first post.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mininovax

  • Newbie
  • *
  • Karma: 1
  • Posts: 44
    • http://www.ondapc.net
[MOD] Pagination mod (sNews 1.5)
« Reply #14 on: December 01, 2006, 05:26:07 pm »

Quote from: keyrocks
Do something like: [Updated on (date)[/b]... and not have the second post. This eliminates any confusion to anyone who tries to use the mod... they will be able to copy and paste the right script from your first post.
I just edited my earlier post with some new stuff, not sure if this is what you mean.


The drawback to this // Pagination script is that if you have 100+ articles, there will be 100+ links ... which is probably not what large sites are looking for.
Logged
Pages: [1] 2