Skip to content

Commit d1ddc1f

Browse files
authored
Merge pull request #2026 from nowackipawel/patch-63
Extension Pager::makeLinks (optional grup name)
2 parents 8401bac + efd20dd commit d1ddc1f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

system/Pager/Pager.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,22 @@ public function simpleLinks(string $group = 'default', string $template = 'defau
147147
* @param integer $page
148148
* @param integer $perPage
149149
* @param integer $total
150-
* @param string $template The output template alias to render.
151-
* @param integer $segment (if page number is provided by URI segment)
150+
* @param string $template The output template alias to render.
151+
* @param integer $segment (if page number is provided by URI segment)
152152
*
153+
* @param string|null $group optional group (i.e. if we'd like to define custom path)
153154
* @return string
154155
*/
155-
public function makeLinks(int $page, int $perPage, int $total, string $template = 'default_full', int $segment = 0): string
156+
public function makeLinks(int $page, int $perPage, int $total, string $template = 'default_full', int $segment = 0, ?string $group = null): string
156157
{
157158
$name = time();
158159

159-
$this->store($name, $page, $perPage, $total, $segment);
160+
$this->store($group ?? $name, $page, $perPage, $total, $segment);
160161

161-
return $this->displayLinks($name, $template);
162+
return $this->displayLinks($group ?? $name, $template);
162163
}
163164

165+
164166
//--------------------------------------------------------------------
165167

166168
/**

user_guide_src/source/libraries/pagination.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ It is also possible to use a URI segment for the page number, instead of the pag
112112

113113
Please note: ``$segment`` value cannot be greater than the number of URI segments plus 1.
114114

115+
If you in need to show many pagers on one page then additional parameter which wil define a group could be helpful::
116+
<?php
117+
$pager = service('pager');
118+
$pager->setPath('path/for/my-group', 'my-group'); // Additionaly you could define path for every group.
119+
$pager->makeLinks($page, $perPage, $total, 'template_name', $segment, 'my-group');
120+
?>
121+
115122
Paginating with Only Expected Queries
116123
=====================================
117124

0 commit comments

Comments
 (0)