Problem/Motivation

I want to set a canonical tag on any page of my drupal installation. Using the default setting for node type pages is no problem. For taxononmies the default term could be changed, too. But here the problem arises. My front page as well as some of my taxonomy term pages are paginated into several parts. So, the URL of the first term page is e.g. http://trekkingschuhe-test.de/tags/trekkingschuh, the URL of the second one then is http://trekkingschuhe-test.de/tags/trekkingschuh?page=1 . In fact, the first URL without the GET parameter is internally handled identically to ?page=0


My idea was to set

[current-page-url]?page=[current-page-number]

as default canonical meta tag in admin/content/taxonomy/edit/vocabulary/1

This does not work, as [current-page-number] does start with 1 not 0. So the resulting canonical URL is just one step to high :-( Setting any page of the paginated list to the same taxonomy URL in the canonical tag would ruin the given backlink structure of sites.

Proposed resolution

Compute [current-page-number] -1 when assigning token or give an alternative token for this issue. I´d prefer a specialized token, that hides this ugly ?page=0

Comments

pdreuw’s picture

Status: Active » Closed (fixed)

Ok, i found out, the issue is not a problem with nodewords but with the token module. I´d applied a patch against token.module which works for me.

123a124,128
>       if ((int)$page > 0) {
>           $values['current-pager-ext'] = "?page=".((int) $page);
>       } else {
>           $values['current-pager-ext'] = "";
>       }
159a165
>     $tokens['global']['current-pager-ext']     = t('The current GET extension for pagination');

This simple patch gives me a new global token, which is counted correctly for any page > 0 and empty for the first page. After applying that patch, you can enter

[current-page-url][current-pager-ext]

als canonical URL with nodewords & nodewords tokens enabled.