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;
CommentFileSizeAuthor
#2 token.tokens.inc_.zip9.61 KBsmitty

Comments

playfulwolf’s picture

Is there any release with code above included?

smitty’s picture

StatusFileSize
new9.61 KB

It 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.

couturier’s picture

This 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.

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)