$provider_top = new ActiveDataProvider([
'query' => Object::find()->where(['status' => 1])->orderBy(['visits'=>SORT_DESC]),
'pagination' => [
'pageSize' => 6,
],
]);
$provider_new = new ActiveDataProvider([
'query' => Object::find()->where(['status' => 1])->orderBy(['added_on'=>SORT_DESC]),
'pagination' => [
'pageSize' => 6,
],
]);
return $this->render('index',['provider_top'=>$provider_top, 'provider_new'=>$provider_new]);
<?=
ListView::widget([
'dataProvider' => $provider_top,
'itemView' => '_view',
'summary' => '',
'options' => ['class'=>'row'],
'itemOptions' => ['class'=>'col-md-4 city-item']
])
?>
<?=
ListView::widget([
'dataProvider' => $provider_new,
'itemView' => '_view',
'summary' => '',
'options' => ['class'=>'row'],
'itemOptions' => ['class'=>'col-md-4 city-item']
])
?>
pageParam
в объекта yii\data\Pagination
$provider_top = new ActiveDataProvider([
'query' => Object::find()->where(['status' => 1])->orderBy(['visits'=>SORT_DESC]),
'pagination' => [
'pageParam' => 'page-top', # <-------------
'pageSize' => 6,
],
]);
$provider_new = new ActiveDataProvider([
'query' => Object::find()->where(['status' => 1])->orderBy(['added_on'=>SORT_DESC]),
'pagination' => [
'pageParam' => 'page-new', # <-------------
'pageSize' => 6,
],
]);
use yii\grid\GridView;
$userProvider->pagination->pageParam = 'user-page';
$userProvider->sort->sortParam = 'user-sort';
$postProvider->pagination->pageParam = 'post-page';
$postProvider->sort->sortParam = 'post-sort';
echo '<h1>Users</h1>';
echo GridView::widget([
'dataProvider' => $userProvider,
]);
echo '<h1>Posts</h1>';
echo GridView::widget([
'dataProvider' => $postProvider,
]);