_category_menu.php
2.15 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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.alias', 'lang.alias')
->where([ 'level' => 0 ])
->all();
?>
<ul class="dropdown-menu <?php echo $isHome ? 'sidebar' : 'sidebar multi-level'; ?>" role="menu" aria-labelledby="dLabel" <?php echo $isHome ? 'id="home-category-anchor"' : ''; ?>>
<?php
foreach ($categories as $category) {
?>
<li class="dropdown-submenu <?=empty($category->categories) ? 'no-child-menu' : ''?>">
<?php
echo Html::a(
$category->lang->title,
'#',
[
'tabindex' => -1,
]
);
if (!empty( $category->categories )) {
?>
<ul class="dropdown-menu">
<?php
foreach ($category->categories as $childCategory) {
echo Html::tag(
'li',
Html::a(
$childCategory->lang->title,
[
'category/view',
'category' => $childCategory->lang->alias->value,
]
),
[
'class' => empty($childCategory->categories) ? 'no-child-menu' : ''
]
);
}
?>
</ul>
<?php
}
?>
</li>
<?php
}
?>
</ul>