Not showing active page from a submenu

Hello,
I’m want to exclude the active page from a submenu. I’m using this loop from Kirby, and I tried $items = $root->children()->listed()->not($site->activePage()) without succes. Do you have the (evident I guess) solution?

<div id="submenu" class="col-6">
  <?php
  $items = false;
  if($root = $pages->findOpen()) {
    $items = $root->children()->listed()->not($site->activePage());
  }
  if($items and $items->isNotEmpty()):
  ?>
  <nav>
    <ul class="submenu">
      <?php foreach($items as $item): ?>
      <li><a class="small"<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
      <?php endforeach ?>
    </ul>
  </nav>
    <?php endif ?>
</div>

What is the point of doing that?

I’ve got the menu (on top) with page and under subpage, in my opinion it makes more sense that if I’m on the Essayez! page, that the link to this page is not visible in the submenu on this page…

So “La mèthod Feldenkrais” and “La mèthod” refer to the same page? But if that is the parent page, why does it appear in the submenu at all?

Could you please post your page structure? It looks as if filtering by isOpen/isActive will not work in this case…

thank you for your patience texnixe :pray: :smiley:, no “la méthode Feldenkrais” is in the main menu, it links to a page where you have a short description of the methode, for whom, and the links to the subpages, and in those links, the one “la méthode” who describe in detail how the methode works… this page will also have the main menu and the others links to the “méthode F.”'s subpages. And it’s here that it makes more sense for me to not have the link to the page I’m currently on, display in the submenu.

Ok, now I think I finally got it… I don’t think it’s a good idea to not show the active page. In a menu, the active page is usually highlighted, so that the user knows where they are. I’d say that’s a best practice.

If you still want to exclude the active subpage, try this:

$items = $root->children()->listed()->filterBy('isActive', false);

Like this it’s working, thank you. Ok maybe I will follow your advice. Then I should had an if condition after the foreach, <?php if($item->isOpen()->filterBy('isActive', true): ?> for the higlighted link, then elseif for the rest of the submenu?

The original code already has this if statement for the active link, no need for anything additional (e($item->isOpen()):

<li><a class="small"<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>

wonderful, many thanks! (Php make me feel like epimetheus…)