diff --git a/src/LinkPager.php b/src/LinkPager.php index 4338288..60be969 100644 --- a/src/LinkPager.php +++ b/src/LinkPager.php @@ -10,6 +10,7 @@ namespace yii\bootstrap5; +use Yii; use yii\base\InvalidConfigException; use yii\data\Pagination; use yii\helpers\ArrayHelper; @@ -148,6 +149,17 @@ class LinkPager extends Widget */ public $disableCurrentPageButton = false; + /** + * @var array Options array for records per page in the pager dropdown. If empty, the page size selection dropdown will not be shown. + * e.g. [5 => '5 per page', 10 => '10 per page', 20 => '20 per page', 50 => '50 per page'] The key is the page size, and the value is the display text. + */ + public $pageSizeOptions = []; + + /** + * @var string|bool the text label for the "goto" page area. Note that this will NOT be HTML-encoded. + * If this property is false, the "goto" page area will not be displayed. + */ + public $goToPageLabel = false; /** * Initializes the pager. @@ -208,6 +220,8 @@ protected function renderPageButtons(): string } $buttons = []; + $buttons[] = $this->renderSelectPageSize(); + $currentPage = $this->pagination->getPage(); // first page @@ -274,12 +288,57 @@ protected function renderPageButtons(): string ); } + $buttons[] = $this->renderGoToPage(); + $options = $this->listOptions; $tag = ArrayHelper::remove($options, 'tag', 'ul'); return Html::tag($tag, implode("\n", $buttons), $options); } + protected function renderSelectPageSize(): string + { + $html = ''; + if (!empty($this->pageSizeOptions)) { + $html .= '