I'm new to Drupal and I've a 'pager' link that shows the second page of a block. It's href attribute is set to something like this '?page=0%2C1' I want it to be simply '#'. It worked by setting $attributes['href'] to '#' in pager.inc but I'm not sure if I'm supposed to modify this file or not.

  • Hacking core is bad, yes - but why would you do this anyway? You're just making sure that clients without Javascript can't navigate your site properly
    – Clive
    Jun 18 '15 at 11:56
  • To be honest I was asked to change those 'href' into '#' by the guy who works on the SEO part. According to him it's better to have '#'.
    – user48663
    Jun 18 '15 at 12:09
  • Yeah, sadly SEO guys are usually far too focused on marketing, they often forget about (or flat out ignore) the real world :) The proper solution for the problem your SEO guy is trying to solve is to make use of a meta canonical tag. That way you don't get penalised for duplicate content, but your website still conforms to disability discrimination laws. However what you're asking is actually pretty simple, let me put an answer in for posterity
    – Clive
    Jun 18 '15 at 12:18

I think we've covered why this might not be a good idea in comments, but to change the output of the pager you just need to override theme_pager_link() in your site's theme.

You'll need to reproduce the original function almost exactly, except you'll probably want to ditch the use of pager_get_query_parameters(), and alter the url() on the penultimate line to use a fragment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.