-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsub-navigation.php
56 lines (52 loc) · 2.47 KB
/
sub-navigation.php
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 $navShowLevels = get_theme_option('nav_show_levels'); ?>
<ul>
<?php foreach ($children as $child): ?>
<?php $hasChildren = $child->hasPages() ?>
<?php if (!$this->navigation()->accept($child)) continue; ?>
<?php if ($child->get("separator") === true): ?>
<li class="divider"></li>
<?php
continue;
endif;
?>
<?php if (!$hasChildren): ?>
<li class="<?php if ($child->isActive()) echo ' active' ?>">
<a
href="<?php echo $child->getHref() ?>"
<?php if ($child->getTarget() != ""): ?>
target="<?php echo $child->getTarget(); ?>"
<?php endif; ?>
>
<?php if ($child->get("icon") !== ""): ?>
<span class="<?php echo $child->get("icon"); ?>"></span>
<?php endif; ?>
<?php echo html_escape($this->translate($child->getLabel())); ?>
</a>
</li>
<?php else:?>
<?php
//check if access is allowed at least one item
$access = false;
foreach ($child->getPages() as $grandChild) {
if ($this->navigation()->accept($grandChild) && $grandChild->get("separator") !== true) {
$access = true;
}
}
if ($access) :
?>
<li<?php if ($child->isActive()) echo ' class="active"' ?>>
<a
href="<?php echo $child->getHref() ?>"
<?php if ($child->getTarget() != ""): ?>
target="<?php echo $child->getTarget(); ?>"
<?php endif; ?> >
<?php echo html_escape($this->translate($child->getLabel())); ?>
</a>
<?php if ($hasChildren && ($navShowLevels !== 0)): ?>
<?php echo $this->partial('sub-navigation.php', ['container'=> $container, 'children' => $child->getPages()]); ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>