Forum Moderators: phranque

Message Too Old, No Replies

Dynamic Pagination Dilemma

How to give users control of page size without causing linking problems

         

Nick_W

8:24 am on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

After struggling all day on a function to create

Prev 1 2 3 Next
links that actually work I've hit a small dilemma:

I'd like to give users the ability to choose how many items they view per page. This means that totalpages/userlimit which gives the amount of pages may be differnent for each user.

The way I do it the url looks like:

somesite.com/prds/34/4

34 = the id of the 'set of prds
4 = the page number

Spot the problem?

If people want to link to specific pages I'll have lots of broken links as users can choose how many items are viewed per page and thus affect the amount of pages per section.

So, the easy way is to fix the limit but, I'd really like to give control to the user whilst not shooting myself in the foot.

I've thought of a few ways around it but they all have flaws. Any ideas guys?

Many thanks...

Nick

graywolf

12:18 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the set of items contained in the set always the same? If so and they request an item thats no longer there, then display an error meassage "...blah, blah, blah we were unable to find the widget(s) you were looking for, these widgets nelow most closely match blah, blah, blah. I also add a "view all" link which has been really well received by people with high speed connections.

Nick_W

12:40 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That won't be an issue.

The last page of items will often be less than all the other pages and you cannot easily miss an item.

I think the 'view all' is good, though you could kind of do that by setting a high limit on items per page.

Looks like I'll have to hard code a limit....

Nick

aspdaddy

4:53 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The way I would do this (in asp) is to put the page size variable in a global/session variable.

Make it default to a value that works for your page indexing, and allow the user to upate the session variable with a new value.

<added>

Another way would be to change the
4 = the page number
to
4= item number that is first on page
The same as google does with start=10,20 etc
</added>

Filipe

7:05 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



Yeah, session variable or cookie will do it.

Or you could pass variables the olde fashioned way w/? and &

graywolf

7:24 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would choose the querystring over sessions or cookies anyday. Gives you (the programmer) all of the control, just make sure it "fails gracefully"

Nick_W

10:22 am on Apr 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>Yeah, session variable or cookie will do it.

No, problem is that giving users control over page size makes linking to pages impossible to regulate. (different users will have diffent page sizes).

I don't see any way other than to hard code it...

Nick

aspdaddy

11:50 am on Apr 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see the problem now. The the only other way is to add another variable to the url:

somesite.com/prds/34/4/8
Where 8 is the page size

I did similar for a site, a default is used but you can add a pagesize to the url if required, I can sticky u an example url if you like?

Nick_W

11:53 am on Apr 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, that's fine thanks I can see what you mean ;)

I'm not keen on adding another var to the url, guess it'll just take some thought as to the pro's and cons.

That's certainly the best way to do it though, so thanks very much for that!

Nick