Do not show subpages in specific main menu item

How do I disable the listing of subpages in a certain main menu item (“Products”) in a tree menu? The subpages are displayed on the page as a list and navigation should only be possible via this. Because of the large number of subpages, the tree menu would be much too long when expanding.

This is the code from my menue-snippet:

  <?php
  $items = $pages->listed();
  if ($items->isNotEmpty()):
	  ?>
	  <ul class="menu-list dark">
		  <?php foreach ($items as $item): ?>
			  <?php $children = $item->children()->listed(); ?>
			  <?php if ($children->isEmpty()): ?>
				  <li class="menu-list-item <?php e($item->isOpen(), 'active') ?>"><a class="alt-font" href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
			  <?php else: ?>
				  <li class="menu-list-item <?php e($item->isOpen(), 'active') ?>"><a href="<?= $item->url() ?>" class="alt-font"><?= $item->title()->html() ?></a>
					  <span class="menu-toggle"></span>
					  <ul class="sub-menu-item">
						  <?php foreach ($children as $child): ?>
							  <li<?php e($child->isOpen(), ' class="active"') ?>><a href="<?= $child->url() ?>"><i class="fa-sharp fa-regular fa-angle-right fa-fw me-2"></i><?= $child->title()->html() ?></a></li>
						  <?php endforeach ?>
					  </ul>
				  </li>
			  <?php endif ?>
		  <?php endforeach ?>
	  </ul>
  <?php endif ?>
<?php
$items = $pages->listed();
if ($items->isNotEmpty()):
  ?>
  <ul class="menu-list dark">
	  <?php foreach ($items as $item): ?>
		  <?php $children = $item->children()->listed(); ?>
			  <li class="menu-list-item <?php e($item->isOpen(), 'active') ?>"><a <?= $children->isEmpty() ? ' class="alt-font"' : '' ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
				  <?php if ($children->isNotEmpty() && $item->is(page('products')) === false): ?>
		      <span class="menu-toggle"></span>
				  <ul class="sub-menu-item">
					  <?php foreach ($children as $child): ?>
						  <li<?php e($child->isOpen(), ' class="active"') ?>><a href="<?= $child->url() ?>"><i class="fa-sharp fa-regular fa-angle-right fa-fw me-2"></i><?= $child->title()->html() ?></a></li>
					  <?php endforeach ?>
				  </ul>
			  </li>
		  <?php endif ?>
	  <?php endforeach ?>
  </ul>
<?php endif ?>
1 Like

Thanks for your quick help on a Sunday!
It worked immediately.