Hello. I am trying to get a submenu that includes the children AND (on top) the $root.
<nav class="sub-nav" role="navigation">
<?php
$items = false;
//get the open item on the first level
if($root = $pages->findOpen()) {
//get visible children for the root item
$items = $root->children()->visible();
}
// only show the menu if items are availlable
if($items and $items->count()): ?>
<ul>
<li><a href="<?php echo $root->url() ?>"><?php echo $root->title() ?></a></li>
<?php foreach($items as $item): ?>
<li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?php echo $item->url() ?>"><?php echo $item->title()->html() ?></a></li>
<?php endforeach ?>
</ul>
</nav>
<?php endif ?>
Now i’d like to have the $root marked as active (when it’s active) like it’s working on the children. But if i use $root->isOpen(), 'class="active"
the root is always marked as active even when i’m on a child page.
Any idea how i can get this thing done? Thanks in advance.