Blame view

frontend/views/search/category.php 4.29 KB
950817c6   Alex Savenko   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  <?php
      /**
       * @var \yii\web\View                     $this
       * @var \common\models\SearchForm         $searchForm
       * @var \yii\data\ActiveDataProvider      $dataProvider
       * @var \artbox\catalog\models\Category[] $categories
       * @var \artbox\catalog\models\Category   $category
       */
      use artbox\catalog\models\Product;
      use yii\bootstrap\ActiveForm;
      use yii\bootstrap\Html;
      use yii\widgets\LinkPager;
      use yii\widgets\ListView;
      
      $view = $this;
      
      $this->params[ 'breadcrumbs' ][] = [
10e74468   mzavalniuk   translate to ua r...
18
          'label' => \Yii::t('app', 'Пошук'),
950817c6   Alex Savenko   first commit
19
20
21
22
23
24
25
          'url'   => [
              'index',
              'word' => $searchForm->word,
          ],
      ];
      $this->params[ 'breadcrumbs' ][] = \Yii::t(
          'app',
10e74468   mzavalniuk   translate to ua r...
26
          'search in category',
950817c6   Alex Savenko   first commit
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
          [
              'category_name' => $category->lang->title,
          ]
      );
  ?>
  <div id="content">
    <div class="container">
      <div class="row">
        <div class="col-sm-offset-3 col-sm-6">
            <?php
                $form = ActiveForm::begin(
                    [
                        'action' => [
                            'category',
                            'categoryId' => $category->id,
                        ],
                        'method' => 'get',
                    ]
                );
                echo $form->field($searchForm, 'word')
                          ->textInput(
                              [
                                  'placeholder' => $searchForm->getAttributeLabel('word'),
                                  'name'        => 'word',
                              ]
                          )
                          ->label(false);
                $form::end();
            ?>
        </div>
      </div>
      <div class="row">
        <div class="col-xs-3">
          <div class="panel panel-default sidebar-menu">
            <div class="panel-body">
              <ul class="nav nav-pills nav-stacked category-menu">
                  <?php
                      foreach ($categories as $item) {
                          echo Html::tag(
                              'li',
                              Html::a(
                                  $item->lang->title,
                                  [
                                      'category',
                                      'categoryId' => $item->id,
                                      'word'       => $searchForm->word,
                                  ],
                                  [
                                      'class' => ( ( $category->id === $item->id ) ? 'active' : '' ),
                                  ]
                              )
                          );
                      }
                  ?>
              </ul>
            </div>
          </div>
        </div>
        <div class="col-xs-9">
            <?php
                if ($dataProvider) {
                    echo ListView::widget(
                        [
                            'options'      => [
                                'class' => 'row products',
                            ],
                            'itemOptions'  => [
                                'tag' => false,
                            ],
                            'layout'       => '{items}',
                            'dataProvider' => $dataProvider,
                            'itemView'     => function ($model) use ($view) {
                                /**
                                 * @var Product $model
                                 */
                                return $view->render(
                                    '@frontend/views/category/_product_item',
                                    [
                                        'product' => $model,
                                    ]
                                );
                            },
                        ]
                    );
                    echo Html::tag(
                        'div',
                        LinkPager::widget(
                            [
                                'pagination' => $dataProvider->pagination,
                            ]
                        ),
                        [
                            'class' => 'pages',
                        ]
                    );
                } else {
10e74468   mzavalniuk   translate to ua r...
123
                    echo \Yii::t('app', 'Введіть текст для пошуку в рядку вище.');
950817c6   Alex Savenko   first commit
124
125
126
127
128
129
                }
            ?>
        </div>
      </div>
    </div>
  </div>