Onepager hide menu entry


#1

Hi guys,
I made an onepager and this is my home template

<?php

snippet('header');

foreach($pages->visible() as $section) {
  snippet($section->uid(), array('data' => $section));
}

snippet('footer');

?>

The first welcome page, which must be visible of course shouldn’t appear in the navigation. How do I do that?

menu code

<div id="offcanvas-nav-primary" uk-offcanvas="overlay: true; flip: true">
    <div class="uk-offcanvas-bar uk-flex uk-flex-column">
      <button class="uk-close-large uk-offcanvas-close" type="button" uk-close></button>
        <ul class="uk-nav uk-nav-primary uk-nav-center uk-margin-auto-vertical">
            <li class="uk-nav-header">Navigation</li>
            <hr>
            <?php foreach($pages->visible() as $item): ?>
            <li><a href="#<?= $item->title() ?>" uk-scroll><?= $item->title()->html() ?></a></li>
            <?php endforeach ?>
        </ul>

    </div>
</div>

#2

Two options:

<?php foreach($pages->visible() as $item): ?>
  <?php if($item->isHomepage()) continue; ?>
   <li><a href="#<?= $item->title() ?>" uk-scroll><?= $item->title()->html() ?></a></li>
<?php endforeach ?>

With continue you leave the loop and continue with the next item. An alternative would be an offset:

<?php foreach($pages->visible()->offset(1) as $item): ?>
   <li><a href="#<?= $item->title() ?>" uk-scroll><?= $item->title()->html() ?></a></li>
<?php endforeach ?>

This loop then only starts with the second item.


#3

Oh I didn’t know about the offset function. Thanks!