For use in the metatag module it would be great if there was a token that returns not only the page number but also a string which indicates that this number is a page number. Moreover it should not appear on the first page.
To get this I added the following code to function token_token_info (after the definition of 'page-number'):
$info['tokens']['current-page']['labeled-page-number'] = array(
'name' => t('Labeled page number'),
'description' => t('The page number of the current page when viewing paged lists (if bigger then 1). Contains the word "page".'),
);
And in function function token_tokens (after the case 'page-number'):
case 'labeled-page-number':
if ($page = filter_input(INPUT_GET, 'page')) {
// @see PagerDefault::execute()
$pager_page_array = explode(',', $page);
$page = $pager_page_array[0];
}
if ($page > 0) {
$replacements[$original] = (string) ' - ' . t('Page') . ' ' . ($page + 1);
}
else {
$replacements[$original] = (string) '';
}
break;
Comments
Comment #1
playfulwolf commentedIs there any release with code above included?
Comment #2
smitty commentedIt should be easy to apply these changes to your token.tokens.inc.
But to help you: Here comes the token.tokens.inc of the last dev-version where I already did the changes.
Comment #3
couturier commentedThis feature request is related to a request to include an option for Views pagination in the Meta Tags module for SEO purposes: http://drupal.org/node/1473422
A release of Tokens has taken place since smitty's last post, so hopefully this code is already in the current Tokens module. I believe this issue applies just to Drupal pagination, though, not pagination within Views.
Comment #4
chris matthews commentedClosing as a duplicate of issue #1337750: Cache clearing for [current-page:page-number] to avoid duplicate page titles in Views and taxonomy term pages