Blame view

frontend/controllers/PageController.php 1.18 KB
e9398092   Administrator   VItaliy 27.11.2015
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  <?php
  namespace frontend\controllers;
  
  
  use common\models\Page;
  use Yii;
  use yii\data\ActiveDataProvider;
  use yii\web\Controller;
  use yii\web\NotFoundHttpException;
  
  
  /**
   * Site controller
   */
  class  PageController extends Controller
  {
      public $layout = '/internal';
  
      public function actionIndex()
      {
          $dataProvider = new ActiveDataProvider([
              'query' => Page::find()->where(['is_active'=>1]),
              'pagination' => [
                  'pageSize' => 16,
              ],
  
          ]);
          return $this->render('index',[
              'dataProvider' => $dataProvider
          ]);
      }
  
      public function actionView($translit)
      {
  
          return $this->render('view', [
              'model' => $this->findModel($translit),
          ]);
      }
  
d17f076f   Administrator   VItaliy 30.11.2015
41
42
43
44
45
46
47
48
49
  
      public function actionAbout($translit)
      {
  
          return $this->render('about_view', [
              'model' => $this->findModel($translit),
          ]);
      }
  
e9398092   Administrator   VItaliy 27.11.2015
50
51
52
53
54
55
56
57
58
59
      protected function findModel($translit)
      {
  
          if (($model = Page::findOne(["code"=>$translit])) !== null) {
              return $model;
          } else {
              throw new NotFoundHttpException('The requested page does not exist.');
          }
      }
  }