Blame view

frontend/views/layouts/_category_menu.php 2.27 KB
6ba3c88a   Alex Savenko   all
1
2
3
4
5
6
7
8
  <?php
      use artbox\catalog\models\Category;
      use yii\bootstrap\Html;
      use yii\web\View;
      
      /**
       * @var View $this
       * @var bool $isHome
2bdb3b90   Виталий   all fix
9
       * @var Category[] $categories
6ba3c88a   Alex Savenko   all
10
       */
2bdb3b90   Виталий   all fix
11
  
879615ba   Виталий   all fix2
12
13
14
15
  $categories = \artbox\catalog\models\Category::find()
      ->with('categories.lang', 'lang.alias')
      ->where([ 'level' => 0 ])
      ->all();
6ba3c88a   Alex Savenko   all
16
  ?>
535b9a3c   Виталий   q2
17
  <ul class="dropdown-menu sidebar" role="menu" aria-labelledby="dLabel" <?php echo $isHome ? 'id="home-category-anchor"' : ''; ?>>
6ba3c88a   Alex Savenko   all
18
19
20
21
      <?php
          foreach ($categories as $category) {
              if ($category->lang->alias) {
                  ?>
65592b6e   Виталий   q3
22
                <li class="dropdown-submenu <?=empty($category->categories) ? 'no-child-menu' : ''?>">
6ba3c88a   Alex Savenko   all
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
61
62
                    <?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>
8ca8678e   Виталий   New changelist45