chrisbeluga / kirby-navigation

Navigation field for getkirby.com
78 stars 13 forks source link

Highlight active menu item #28

Open LordCanis opened 2 years ago

LordCanis commented 2 years ago

Hey,

thanks for the awesome plugin. Is it possible to highlight the active menu item?

I use:

<?php foreach($site->navigation()->toStructure() as $navigation): ?>
  <li>
    <a <?php e($navigation->isOpen(), 'aria-current') ?> id="<?php echo $navigation->id() ?>"  href="<?php echo $navigation->url(); ?>" <?php echo $navigation->popup()->toBool() ? 'rel="noopener noreferrer" target="_blank"' : '' ?>>
  <?php echo $navigation->text() ?>
    </a>
  </li>
 <?php endforeach ?>

and insert in the a-Tag this

<?php e($navigation->isOpen(), 'aria-current') ?>

Than all items are highlighted. What am I doing wrong?

Thanks for your help!

Sean-OShea commented 2 years ago

@LordCanis felt on the same issue, a workaround was given in this issue #18 in the last comment, it worked for me with kirby 3.7.3 with the navigation plugin version 3.0.0