Answer the question
In order to leave comments, you need to log in
How to make such advanced pagination in yii2?
Good day. There is such a pagination (this is the layout of the portal, which needs to be put on yii2).
In the portal itself, when I added pagination, I got the following view
. What the framework gave by default is not quite what you need. The picture below shows the desired result.
Answer the question
In order to leave comments, you need to log in
Very simple. Change the default settings in the DI container of this class.
1. Using DI Container
<?php
declare(strict_types=1);
namespace frontend\bootstrap;
use Yii;
use yii\base\BootstrapInterface;
use yii\di\Container;
use yii\widgets\LinkPager;
/**
* @author Maxim Vorozhtsov <myks1992@mail.ru>
*/
class Bootstrap implements BootstrapInterface
{
/**
* @inheritDoc
*/
public function bootstrap($app)
{
/** @var Container $container */
$container = Yii::$container;
$container->set(LinkPager::class, [
'prevPageLabel' => false,
'nextPageLabel' => false,
'maxButtonCount' => 3,
]);
}
}
'container' => [
'singletons' => [
CheckAccessInterface::class => yii\rbac\DbManager::class,
IdentityInterface::class => function () {
return Yii::$app->user->getIdentity();
},
],
],
'bootstrap' => [
frontend\bootstrap\Bootstrap::class
],
<?php
declare(strict_types=1);
namespace frontend\widgets;
class LinkPager extends \yii\widgets\LinkPager
{
public $prevPageLabel = false;
public $nextPageLabel = false;
public $maxButtonCount = 3;
}
Yii::$container->set('yii\widgets\LinkPager', 'frontend\widgets\LinkPager');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question