views:

473

answers:

4

I'm currently working on an in-house CMS and have come to a bit of a standstill. I'm trying to make it easy to paginate between pages of posts in a blog, and can't decide on how it should be tackled. The real problem only arises when I need to allow a user to choose how many results to display per page or the order to sort posts in.

My initial thought was to simply use a querystring: blog/?page=3&count=20&sort=date but I'm not sure whether this method will have adverse effects on SEO.

For example, is Google sensible enough to realise that blog/?page=3&count=20 is the same as blog/?count=20&page=3?

I then thought about using sessions, but again this does not solve the problem above, and possibly makes it worse as some users may not have cookies enabled.

Lastly, I'm already using mod_rewrite for some of the urls, would it be best to use a structure like this: blog/1/20/?

I could really do with some help/suggestions here, there doesn't seem to be a hard-and-fast way of paginating results.

Thanks in advance

A: 

As long as those query strings are present on the links on your site (via static, normal 'paging' links which are spiderable) there shouldn't be any adverse effects. If your paging happens via sessions, however, that could have an impact, as that's usually done via cookies or by a long query-string propagated session ID. As far as I know, the order of parameters does not matter, as long as they yield the same output from the server.

The simple GET query string paging method works nicely. Google does it too (e.g.: q=test&start=10&...), the point is to make sure everything is reachable via plain-vanilla anchors.

karim79
A: 

Avoid using querystrings if you plan your site to get crawled satisfactorily.

Instead, use mod_rewrite and queries like this:

blog/page:3/count:20/sort:date

That will make it more readable, while keeping querystrings out of the way.

Of course, you'll have to parse that before doing the actual query, but it's something fairly simple to do in PHP: using explode() you separate each part of the URI, then parse from there.

Consider not having the order of the parameters fixed, instead allow them to be swapped and omitted, which will give you more flexibility when building the links.

Seb
A: 

I have always done this with session variables that get set via ajax calls.

I set an onClick event for each column header, and wrap the contents of the page in a div, so I can replace it.

I don't want Google downloading 10 different versions of the same page anyway.

Daren Schwenke
But then how do you cater for users who have cookies disabled? Or JavaScript turned off?
Rowan
A: 

On your comment about session variables:

I then thought about using sessions, but again this does not solve the problem above, and possibly makes it worse as some users may not have cookies enabled.

Session variables are stored on the server and not the client, so disabling cookies does not affect session variables.

Session variables are probably the easiest and most reliable way to solve this problem if you want to avoid google duplication issues.

chris
I know session variables are stored on the server, but a session ID still needs to be stored on the client (in a cookie or querystring)
Rowan