xref: /webtrees/resources/views/components/menu-item.phtml (revision 00b1984e374faddab4698e73088f0c964e529b65)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Menu;
6
7/**
8 * @var Menu $menu
9 */
10
11?>
12
13<?php if ($menu->getSubMenus() !== []) : ?>
14    <li class="nav-item dropdown <?= $menu->getClass() ?>">
15        <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
16            <?= $menu->getLabel() ?>
17            <span class="caret"></span>
18        </a>
19        <div class="dropdown-menu" role="menu">
20            <?php foreach ($menu->getSubmenus() as $submenu) : ?>
21                <a
22                    class="dropdown-item <?= $submenu->getClass() ?>"
23                    href="<?= e($submenu->getLink()) ?>"
24                    role="menuitem"
25                    <?php foreach ($submenu->getAttrs() as $key => $value) : ?>
26                        <?= e($key) ?>="<?= e($value) ?>"
27                    <?php endforeach ?>
28                >
29                    <?= $submenu->getLabel() ?>
30                </a>
31
32            <?php endforeach ?>
33        </div>
34    </li>
35<?php else : ?>
36    <li class="nav-item <?= $menu->getClass() ?>">
37        <a
38            class="nav-link"
39            href="<?= e($menu->getLink()) ?>"
40            <?php foreach ($menu->getAttrs() as $key => $value) : ?>
41                <?= e($key) ?>="<?= e($value) ?>"
42            <?php endforeach ?>
43        >
44            <?= $menu->getLabel() ?>
45        </a>
46    </li>
47<?php endif ?>
48