Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old March 23rd, 2006, 12:57 PM
rosslad rosslad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 rosslad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Image Gallery 2.0 by Notepad - Pagination Function

Hi there,
I am using this fantastic script by notepad.
As my gallery is growing now I was wondering if anybody else using the script has changed the pagination function to include page numbers? ie:
prev 123456 next

I am not a coder myself so wouldnt know where to begin but if anybody knows of a way to do this please let us know.

Ross

Reply With Quote
  #2  
Old April 12th, 2006, 11:50 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Image Gallery 2.0 by Notepad - Pagination Function

you'd want to focus on the navigate_images() function. which for reference i've included below.
php Code:
Original - php Code
  1.  
  2. // draw previous and next links for images
  3. function navigate_images($total) {
  4.     global $section, $file, $prev, $next, $end, $pg;
  5.     $query = !empty($file) ? '?file='.rawurlencode($file).'&pg=' : '?pg=';
  6.     $pages = $total <= $section ? 1 : ceil($total / $section);
  7.     $p = '<<-<a href="'.SELF.$query.$prev.'">prev</a>';
  8.     $n = '<a href="'.SELF.$query.$next.'">next</a>->>';
  9.     $c = ' : page '.$pg.' of '.$pages.' : ';
  10.    
  11.     print('<div class="navigate_images">'."rn");
  12.     if(($pg == 1 && $end >= $total))
  13.         print('<<-prev'.$c.'next->>');
  14.     elseif($pg == 1)
  15.         print('<<-prev : '.$c.' : '.$n);
  16.     elseif($end < $total)
  17.         print($p.' : '.$c.' : '.$n);
  18.     else
  19.         print($p.' : '.$c.' : next->>');
  20.        
  21.     print("rn".'</div>'."rn");
  22. }

now while i won't make the changes for you, cause i don't have time, here is a similar function i wrote which does what you want. you should be able figure out how to use this example to modify the code above to your liking.
php Code:
Original - php Code
  1.  
  2. function paginate($display, $pg, $total) {
  3.     $pages = $total <= $display ? 1 : ceil($total / $display);
  4.     $query = isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'].'&pg=' : '?pg=';
  5.     $first = '<a href="'.$_SERVER['PHP_SELF'].$query.'1">«</a>';
  6.     $prev = '<a href="'.$_SERVER['PHP_SELF'].$query.($pg - 1).'">‹</a>';
  7.     $next = '<a href="'.$_SERVER['PHP_SELF'].$query.($pg + 1).'">›</a>';
  8.     $last = '<a href="'.$_SERVER['PHP_SELF'].$query.$pages.'">»</a>';
  9.    
  10.     echo '<div><p align="center">';
  11.     echo $pg > 1 ? "$first : $prev :" : '« : ‹ :';
  12.    
  13.     // i want to display a max of 9 links
  14.     $begin = $pg < 6 ? 1 : $pg - 4;
  15.     $end = $begin + 8;
  16.     while($end > $pages)
  17.         $end--;
  18.     for($i=$begin; $i<=$end; $i++)
  19.         echo $i == $pg ? ' ['.$i.'] ' : ' <a href="'.$_SERVER['PHP_SELF'].$query.$i.'">'.$i.'</a> ';
  20.    
  21.     echo $pg < $pages ? ": $next : $last" : ': › : »';
  22.     echo '</p></div>'."rn";
  23. }
  24. $display = 25;
  25. $pg = isset($_REQUEST['pg']) && ctype_digit($_REQUEST['pg']) ? $_REQUEST['pg'] : 1;
  26. $start = $display * $pg - $display; // defined for database query's using LIMIT
  27. $total = count($news);

Reply With Quote
  #3  
Old April 13th, 2006, 09:39 AM
rosslad rosslad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 rosslad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Image Gallery 2.0 by Notepad - Pagination Function

hey thanks notepad,
I will certainly give it a try.

thanks for responding
Ross

Reply With Quote
  #4  
Old April 19th, 2006, 07:10 AM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Image Gallery 2.0 by Notepad - Pagination Function

okay i changed my mind and did it for you. also corrected a few of my own mistakes O_O just replace the old function with this one.
php Code:
Original - php Code
  1.  
  2. function navigate_images($total) {
  3.     global $section, $pg; // we no longer need $file, $prev, $next, or $end
  4.     $pages = $total <= $section ? 1 : ceil($total / $section);
  5.  
  6.     if(trim($_SERVER['QUERY_STRING']) != '') {
  7.         if(stristr($_SERVER['QUERY_STRING'], 'pg='))
  8.             $query = '?'.preg_replace('/pg=d+/', 'pg=', $_SERVER['QUERY_STRING']);
  9.         else
  10.             $query = '?'.$_SERVER['QUERY_STRING'].'&pg=';
  11.     } else
  12.         $query = '?pg=';
  13.  
  14.     $first = '<a href="'.$_SERVER['PHP_SELF'].$query.'1">«</a>';
  15.     $prev = '<a href="'.$_SERVER['PHP_SELF'].$query.($pg - 1).'">‹</a>';
  16.     $next = '<a href="'.$_SERVER['PHP_SELF'].$query.($pg + 1).'">›</a>';
  17.     $last = '<a href="'.$_SERVER['PHP_SELF'].$query.$pages.'">»</a>';
  18.    
  19.     echo '<div class="navigate_images">';
  20.     echo $pg > 1 ? "$first : $prev :" : '« : ‹ :';
  21.    
  22.     // this is to display a max of 9 links
  23.     $begin = $pg < 6 ? 1 : $pg - 4;
  24.     $end = $begin + 8;
  25.     while($end > $pages)
  26.         $end--;
  27.     for($i=$begin; $i<=$end; $i++)
  28.         echo $i == $pg ? ' ['.$i.'] ' : ' <a href="'.$_SERVER['PHP_SELF'].$query.$i.'">'.$i.'</a> ';
  29.    
  30.     echo $pg < $pages ? ": $next : $last" : ': › : »';
  31.     echo '</div>'."rn";
  32. }

Reply With Quote
  #5  
Old April 19th, 2006, 09:49 AM
rosslad rosslad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 rosslad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Image Gallery 2.0 by Notepad - Pagination Function

hey again notepad,
thanks a million, I was struggling to get it to work, now it works like a charm.

Many Thanks
Ross

Reply With Quote
  #6  
Old April 23rd, 2007, 10:29 PM
guille guille is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 guille User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 25 sec
Reputation Power: 0
Hello there... this is an awsome script, i´m implementing it on my site... but i have 2 questions:

1- Can i open the image on the same "thumbnails page" with a back to the gallery link? i can´t figure it out.

2- Can i disable the middle mouse button to prevent te user from opening multiple windows?

Any ideas are wellcome =)
Thanks in advance.


Bill.

Reply With Quote
  #7  
Old April 29th, 2007, 07:53 PM
guille guille is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 7 guille User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 25 sec
Reputation Power: 0
Ok... i modified the script and all working fine.... except for this problem:

(URL address blocked: See forum rules)

Now... while i trying to solve that problem.... Anyone have some advice to optime the scirpt to reduce server load?
I think something about cache.. not to load the same page everytime... for example iam on page 1... i go to page 2... when i come back to page 1... all loading again. =P

Thanks in advance.

Reply With Quote
  #8  
Old June 19th, 2007, 08:11 PM
bbybls bbybls is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holts Summit, MO, USA
Posts: 10 bbybls User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 26 sec
Reputation Power: 0
Send a message via Yahoo to bbybls
Question Please help with this pagination for image gallery

I am new to coding php and have used this image gallery. I love it, because it is easy to use. But I came across this pagination edit for it and followed the directions to have the different pages at the top and bottom. I would like to have this feature for the image gallery, but after clicking on two or three pages all of the thumbnails go away. I can't even get back to the first page by using the arrow. Please help, I inserted just like it said and am having issues getting the code to work.

Thank you in advance
Carrie

Last edited by bbybls : June 19th, 2007 at 08:13 PM.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > Image Gallery 2.0 by Notepad - Pagination Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML c