This must be trivial but I can’t figure out how to detect wether a child page of my current page is active.
There is a function isDescendantOfActive() but unfortunately not isAncestorOfActive().
I want to add class=is-current to the element with class=has-dropdown not only when that page is open but also when one of its descendants are:
<div class="navbar">
<?php foreach($items as $item):
$children = $item->children()->visible();
if($children->count() > 0): ?>
<div class="navbar-item has-dropdown <?php e($item->isOpen(), ' is-current') ?>">
<a class="navbar-link">
<?= $item->title()->html() ?>
</a>
<div class="navbar-dropdown">
<?php foreach($children as $child): ?>
<a class="navbar-item <?php e($child->isOpen(), ' is-current') ?>" href="<?php echo $child->url() ?>">
<?= $child->title()->html() ?>
</a>
<?php endforeach ?>
</div>
</div>
<?php endif ?>
<?php endforeach ?>
</div>
How would i do that?