The pages display tables via GridView :: widget, so that everyone does not prescribe

'pager' => [ 'firstPageLabel' => 'First', 'lastPageLabel' => 'Last', ], 

I want to automate it somehow. I found the getLinks method in Pagination.php, it just says what you need to go

 public function getLinks($absolute = false) { $currentPage = $this->getPage(); $pageCount = $this->getPageCount(); $links = [ Link::REL_SELF => $this->createUrl($currentPage, null, $absolute), ]; if ($currentPage > 0) { $links[self::LINK_FIRST] = $this->createUrl(0, null, $absolute); $links[self::LINK_PREV] = $this->createUrl($currentPage - 1, null, $absolute); } if ($currentPage < $pageCount - 1) { $links[self::LINK_NEXT] = $this->createUrl($currentPage + 1, null, $absolute); $links[self::LINK_LAST] = $this->createUrl($pageCount - 1, null, $absolute); } return $links; } 

But how and where to call this method correctly?

    2 answers 2

    If you are using a GridView , then:

     <?= GridView::widget([ 'pager' => [ 'firstPageLabel' => 'Первая страница', 'lastPageLabel' => 'Последняя страница' ], ... ]) ?> 

    If you use pagination with the LinkPager widget, then:

     <?= yii\widgets\LinkPager::widget([ //все остальное 'firstPageLabel' => 'Первая', 'lastPageLabel' => 'Последняя' ]); ?> 

      Create your MyPager , check on the default, configure everything you need there. And in any GridView specify your class MyPager .