Blame view

frontend/views/layouts/_category_menu.php 2.22 KB
6ba3c88a   Alex Savenko   all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <?php
      use artbox\catalog\models\Category;
      use yii\bootstrap\Html;
      use yii\web\View;
      
      /**
       * @var View $this
       * @var bool $isHome
       */
      $categories = Category::find()
                            ->with('categories.lang', 'lang')
                            ->where([ 'level' => 0 ])
                            ->all();
  ?>
535b9a3c   Виталий   q2
15
  <ul class="dropdown-menu sidebar" role="menu" aria-labelledby="dLabel" <?php echo $isHome ? 'id="home-category-anchor"' : ''; ?>>
6ba3c88a   Alex Savenko   all
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
      <?php
          foreach ($categories as $category) {
              if ($category->lang->alias) {
                  ?>
                <li class="dropdown-submenu">
                    <?php
                        echo Html::a(
                            $category->lang->title,
                            [
                                'category/view',
                                'category' => $category->lang->alias->value,
                            ],
                            [
                                'tabindex' => -1,
                            ]
                        );
                        if (!empty($category->categories)) {
                            ?>
                          <ul class="dropdown-menu">
                              <?php
                                  foreach ($category->categories as $childCategory) {
                                      if ($childCategory->lang->alias) {
                                          echo Html::tag(
                                              'li',
                                              Html::a(
                                                  $childCategory->lang->title,
                                                  [
                                                      'category/view',
                                                      'category' => $childCategory->lang->alias->value,
                                                  ]
                                              )
                                          );
                                      }
                                  }
                              ?>
                          </ul>
                            <?php
                        }
                    ?>
                </li>
                  <?php
              }
          }
      ?>
  </ul>