Hello, I am having trouble getting an ‘active’ class added to the current page in a navigation menu using the kirby navigation plug-in, using the code below I get an ‘active’ class added to every menu item, any idea’s on how to solve this would be greatly appreciated.
<nav>
<ul class="nav-list">
<?php foreach($site->mainnavigation()->toStructure() as $navigation): ?>
<li <?php e($navigation->isOpen(), 'class="active"') ?>><a aria-label="<?php echo $navigation->text() ?>"
href="<?php echo $navigation->url(); ?>"><?php echo $navigation->text() ?></a>
<?php if($navigation->children()->isNotEmpty()): ?>
<ul class="menu vertical nested">
<?php foreach($navigation->children()->toStructure() as $children): ?>
<li <?php e($children->isOpen(), 'class="active"') ?>><a aria-label="<?php echo $children->text() ?>"
href="<?php echo $children->url() ?>"><?php echo $children->text() ?></a>
<?php if($children->children()->isNotEmpty()): ?>
<ul class="menu vertical nested">
<?php foreach($children->children()->toStructure() as $subchildren): ?>
<li <?php e($subchildren->isOpen(), 'class="active"') ?>><a aria-label="<?php echo $subchildren->text() ?>"
href="<?php echo $subchildren->url() ?>"><?php echo $subchildren->text() ?></a></li>
<?php endforeach ?>
</ul>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
</nav>