Пример #1
0
 /**
  * Lists all TblPost models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => TblPost::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Пример #2
0
<?php

use yii\widgets\ListView;
use app\models\TblPost;
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
use app\config\conf;
$this->title = 'My Yii Application';
?>
<center>
	<div class="site-index" style="width:60%;"> 
	
		<?php 
$dataProvider = new ActiveDataProvider(['query' => TblPost::find(), 'pagination' => ['pageSize' => conf::$numberpostperpage], 'sort' => ['defaultOrder' => ['publish_date' => SORT_DESK]]]);
echo ListView::widget(['dataProvider' => $dataProvider, 'itemView' => '_post']);
?>
	</div>
</center>