Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow specifying tag for current page number. Closes #2892

  • Loading branch information...
commit 61dd1098d381f097c33f30c2bdfca8d252639547 1 parent 57681ff
@ADmad ADmad authored
View
22 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
@@ -1436,6 +1436,28 @@ public function testNumbers() {
);
$this->assertTags($result, $expected);
+ $result = $this->Paginator->numbers(array('first' => 1, 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'a'));
+ $expected = array(
+ array('li' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/li',
+ ' | ',
+ array('li' => array('class' => 'active')), array('a' => array()), '2', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/li',
+ ' | ',
+ array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
+ );
+ $this->assertTags($result, $expected);
+
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
$expected = array(
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
View
12 lib/Cake/View/Helper/PaginatorHelper.php
@@ -650,6 +650,7 @@ public function counter($options = array()) {
* - `ellipsis` Ellipsis content, defaults to '...'
* - `class` Class for wrapper tag
* - `currentClass` Class for wrapper tag on current active page, defaults to 'current'
+ * - `currentTag` Tag to use for current page number, defaults to null
*
* @param array $options Options for the numbers, (before, after, model, modulus, separator)
* @return string numbers string.
@@ -664,7 +665,8 @@ public function numbers($options = array()) {
$defaults = array(
'tag' => 'span', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null,
- 'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...', 'currentClass' => 'current'
+ 'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...',
+ 'currentClass' => 'current', 'currentTag' => null
);
$options += $defaults;
@@ -678,7 +680,7 @@ public function numbers($options = array()) {
extract($options);
unset($options['tag'], $options['before'], $options['after'], $options['model'],
$options['modulus'], $options['separator'], $options['first'], $options['last'],
- $options['ellipsis'], $options['class'], $options['currentClass']
+ $options['ellipsis'], $options['class'], $options['currentClass'], $options['currentTag']
);
$out = '';
@@ -714,7 +716,11 @@ public function numbers($options = array()) {
if ($class) {
$currentClass .= ' ' . $class;
}
- $out .= $this->Html->tag($tag, $params['page'], array('class' => $currentClass));
+ if ($currentTag) {
+ $out .= $this->Html->tag($tag, $this->Html->tag($currentTag, $params['page']), array('class' => $currentClass));
+ } else {
+ $out .= $this->Html->tag($tag, $params['page'], array('class' => $currentClass));
+ }
if ($i != $params['pageCount']) {
$out .= $separator;
}
Please sign in to comment.
Something went wrong with that request. Please try again.