SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sort of pagination

    I have a poem site and I don't want the pagination where it is the numbers. Since each page is one poem, I want the numbers to be the poem titles. It will display 11 poems at a time (the surrounding ones). So the current poem will be in the middle surrounded by the next 5 and previous 5. But if it is the second poem it will have 1 in front and 9 following, same if the poem is one of the last ones. Any ideas on how to go about this or where to start? I appreciate any help I can get.

  2. #2
    SitePoint Zealot backtobasics's Avatar
    Join Date
    Aug 2006
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be simple enough to replace the numbers with the corresponding title.

    Though, this (more than likely) will look rather ugly if you have poems with fairly large titles.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed how I'm going about it. I'm not going to list the poems around the one I'm viewing. Instead it will just list them in a select box based in 10 poem increments. Only one poem will be displayed on the page at a time, but you can select poems through the select box. So if you are viewing any of the first ten poems from the database, they will all have the same titles in the select box, but if you are viewing the 11th poem the select box will show poems 11-20. I looked at pagination tutorials, but they rely on page numbers, so not sure how to go about this. the url looks like
    Code:
    www.site.com/poems/poem-title
    So it isn't passing page numbers. I guess in short I have to figure which group the poem belongs to based on poem_id, I can't seem to think of a formula though.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <option value="4">foo</option>
    <option value="5">bar</option>
    <option value="6">baz</option>
    where 4, 5, and 6 are the id numbers from the database(or just which which record in the sequence).
    then, just grab the value submitted by the browser. now you know where to start calculating your range.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I can figure that part, but that isn't the problem. I can't populate the select list without knowing what set of 10 I'm on. If they go to the address of the 11th poem, how do I know to show 11-20 in the select box?

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    limit x, 10

    x coming from the select menu.

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I appreciate the help, I do, but I don't think you are understanding where the problem is. When the page loads there isn't a default select case. If they go to the address of the 7th poem I'd have select options 1-10, if they go to the 13th poem, now the select options are poems 11-20. I'm trying to think of a formula for this, because in the end I'll have previous and next links, next and previous 10. Maybe there isn't a way to even do this I don't know. Beginning to think I'll have to settle for always having the current poem first and listing the following nine. Then the next link saying to start at 10 + poem_id and the previous to start at 10 - poem_id I just liked the idea of having them in groups of 10.

  8. #8
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where $id is the id of the poem:

    Code:
    $remainder = $id &#37; 10;
    $start_display = $id - $remainder;
    Then do limit $start_display, 10

    Something like that should work

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes!! I think that will work, but I'd have to add 1 to start_display since 1-10 result in 0, but should be fine. Hopefully I can figure out the rest, being the previous and next links. But thanks for the help for the current problem.


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
  •