Paginate Your Site Like Digg

July 7, 2006 at 4:09 pm

Some people were interested in seeing the code I used to create the pagination for WineLog, which was based on the style of pagination used on sites like Digg and Flickr. I’ve put together a little demo which should help out anyone who is trying to create the same effect on their site.

Screenshot of Digg-Style Pagination in Action

(digg-style pagination demo)

56 Responses to “Paginate Your Site Like Digg”

  1. martin says:

    Hi

    i have a problem my pages start at zero and i want them to show as page one and the link to still show the zero

    so it would look like this

    1 2 3 4 <—- the link for number one should be page=0 and link for number 2 should be page=1 ect

    any idea how i can do that

  2. health says:

    nice info..
    good for me and all

  3. Jan says:

    Thats great! But I can´t use “page” as an element, because it´s already taken by my cms. Is it possible to change that?
    I changed “page” already 3 times to “site”:

    if ( (int)$_GET['site'] > 1 ) $page = (int)$_GET['site'];
    $pagestring = “?site=”)

    and it begins to work, but I think I missed something. Any hints?

  4. Randal says:

    Script looks great and had it installed on my page in about 10 minutes. It displays the correct number of items ( as per limit) on the first page just fine and calculates the proper number of pages to use in pagination menu bar. The pagination menu bar looks great. Problem is… I only get results on the first page. All of the other pages come up with blank results. In my test, there are 7 items to display, have the limit set to 3, pagination menu shows there are 3 pages of results and the pagination button links show the correct link address. But, if I click on button [2] (or other) it delivers blank results I’m reasonably fair with php and have spent a number of hours trying to get it to work right and unfortunately it’s just not happening. Any advice would be greatly appreciated. (website address is link to test page.)

  5. jason says:

    @Randal, make sure you get the $page var by adding $page = $_REQUEST['page']; to the top of your script.

    I really need to update the script/demo.

    If that doesn’t work, try echoing the SQL query being made and running that through phpMyAdmin or something to see if there are errors. I’m guessing the SQL query is not being put together correctly.

Leave a Reply

* Required
* Required, Private