Skip to content

Commit

Permalink
Allow URL #hash for scoped paginator links
Browse files Browse the repository at this point in the history
  • Loading branch information
garas committed Jan 6, 2018
1 parent 28400cb commit 72cbe47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/View/Helper/PaginatorHelper.php
Expand Up @@ -553,6 +553,12 @@ public function generateUrlParams(array $options = [], $model = null)
if (!empty($paging['scope'])) {
$scope = $paging['scope'];
$currentParams = $this->_config['options']['url'];

if (isset($url['#'])) {
$currentParams['#'] = $url['#'];
unset($url['#']);
}

// Merge existing query parameters in the scope.
if (isset($currentParams['?'][$scope]) && is_array($currentParams['?'][$scope])) {
$url += $currentParams['?'][$scope];
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/View/Helper/PaginatorHelperTest.php
Expand Up @@ -910,6 +910,10 @@ public function testGenerateUrlMultiplePagination()
$result = $this->Paginator->generateUrl(['sort' => 'name']);
$expected = '/posts/index?article%5Bpage%5D=3&article%5Bsort%5D=name';
$this->assertEquals($expected, $result);

$result = $this->Paginator->generateUrl(['#' => 'foo']);
$expected = '/posts/index?article%5Bpage%5D=3#foo';
$this->assertEquals($expected, $result);
}

/**
Expand Down

0 comments on commit 72cbe47

Please sign in to comment.