Example #1
0
 public function actionIndex()
 {
     $this->view->titlePage = "Список постов";
     $criteria = ['where' => 'active=:active', 'order' => 'date_update DESC'];
     $params = [':active' => 1];
     $pageSize = 2;
     $pagination = new core\Pagination(Post::instance(), $criteria, $params, $pageSize);
     $criteria['limit'] = $pagination->getLimit();
     $posts = Post::instance()->findAll($criteria, $params);
     $params = ['posts' => $posts, 'pagination' => $pagination->getPaginate()];
     if (Request::isAjax()) {
         echo $this->view->render("index", $params, false, false);
         exit;
     } else {
         $this->view->render("index", $params);
     }
 }