Index: token.tokens.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/token/token.tokens.inc,v retrieving revision 1.7 diff -u -p -r1.7 token.tokens.inc --- token.tokens.inc 5 Jul 2010 05:43:23 -0000 1.7 +++ token.tokens.inc 21 Jul 2010 05:48:15 -0000 @@ -95,6 +95,16 @@ function token_token_info() { 'type' => 'menu-link', ); + // Current page tokens. + $info['types']['current-page'] = array( + 'name' => t('Current page'), + 'description' => t('Tokens related to the current page request.'), + ); + $info['tokens']['current-page']['page-number'] = array( + 'name' => t('Page number'), + 'description' => t('The page number of the current page when viewing paged lists.'), + ); + return $info; } @@ -170,6 +180,22 @@ function token_tokens($type, $tokens, ar } } + // Current page tokens. + if ($type == 'current-page') { + foreach ($tokens as $name => $original) { + switch ($name) { + case 'page-number': + if ($page = filter_input(INPUT_GET, 'page')) { + // @see PagerDefault::execute() + $pager_page_array = explode(',', $page); + $page = $pager_page_array[0]; + } + $replacements[$original] = (int) $page + 1; + break; + } + } + } + // Entity tokens. if (!empty($data[$type]) && $entity_type = _token_get_entity_from_token_type($type)) { $entity = $data[$type];