SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php and page numbers - how to reduce to

    Here's what I've got:

    Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 and it continues to page 577!!!

    What I want to achieve is something like:
    Page 1 of 577 1 2 3 4 5 11 51 101 501 > Last


    I've isolated the code for the 577 string of pages down to:
    Code:
    //Display Pages
    	if($numListings > PERPAGE && empty($searchTerms)) {
    		$directory .= "<div style='margin:3px 0 8px 0;padding-bottom:2px;border-bottom:1px solid black;'><b>Pages:</b>";
    		$remaining = $numListings - PERPAGE;
    		$count = 0;
    		while($remaining > -1 * PERPAGE) {
    			$index = PERPAGE * $count++;
    			$directory .= "&nbsp;&nbsp;";
    			if($offset >= $index && $offset < $index + PERPAGE)
    				$directory .= "$count";
    			else
    				$directory .= "<a style='cursor:pointer' onClick='bizdir_change_listings_page(".(($count - 1) * PERPAGE).")'>$count</a>";
    			$remaining -= PERPAGE;
    		}
    		$directory .= "</div>";
    	}
    What would I have to change to limit the number of pages shown and add a Last or more... link?

    Thanks for your help,

    Charles

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    Hi csmith, welcome to the forums (posting-wise),

    The limit of the pages shown comes from the PERPAGE constant. It may look something like
    PHP Code:
    define('PERPAGE'##); 
    in a config file, or it may come from a database holding the value.

    What pagination script are you using?

  3. #3
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply. It's from a wordpress plugin. Found the perpage define and have changed it to many more entries per page than the original 30.

    Charle


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •