This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

What's a Pagination Helper?

The Pagination Helper is used by several core blocks. Perhaps most notably, the Page List uses it to create numbered navigation menus that look like this:


Dealing with spiders

However, you may want to tell web spiders not to index all these numeric links. If you have a ton of pages listed on a ton of other pages, spiders can sometimes get "stuck" redundantly mapping and indexing all these links. Depending on your site's structure and your server's performance, it might be a good idea to tell Google (and its peers) to ignore these particular pagination links.

Let's implement it!

Google recommends adding a rel="nofollow" attribute to your anchor (aka link) tags to help their bots identify such links. So how do we do this?

First, make sure your site's Override Cache is turned off. Locate your Pagination Helper:


and save a new copy of the file in the proper overrides directory:


Next we'll edit this copy of the helper. Name the class so that concrete5 recognizes it as an override of the core class. See this article for more info on overriding classes in concrete5.6 and later.

class PaginationHelper extends Concrete5_Helper_Pagination {

We'll cut out all the functions we don't need to override. The one we're interested in is the getPages() function. Keep this whole block intact, but find the final else clause as we loop through the returned list of pages. This is the chunk of code that returns links to other pages on our site. Then we'll just add our rel="nofollow" to the HTML that gets concatenated together, making sure to escape our double quotes where necessary. Right after we run "getJSFunctionCall", we'll just tack our attribute in before the end of the opening anchor tag:

$this->getJSFunctionCall($i+1)." rel=\"nofolllow\">"  

Note that there's handling here for producing list elements and also plain span elements, so make sure to alter both if you want to affect all varieties of pagination around your site.

And that's it! Refresh a page with a pagination element and you should see rel="nofollow" in the page's source. Once your override is in place, make sure to turn your caches back on if applicable.

To see the completed example, download this modified pagination.php!

Loading Conversation