Kirby

Fetch list of UNLISTED pages without specific pages

I want to get all unlisted pages to list them in the footer section, but this list shouldn’t include specific pages: such as Home, Error

I use this code:

<ul>
  <?php foreach($site->children()->unlisted() as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= html($subpage->title()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

How can I exclude specific pages?

The not() method is your friend:

<ul>
  <?php foreach($site->children()->unlisted()->not('error', 'home') as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= html($subpage->title()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>
1 Like

thanks sonja.
kirby is so nice and simple :blush::+1:. I just have to finde the answers myself.

1 Like

Yep, in the long run it pays off to get a decent overview of the API and its possibilities. You don’t have to know everything from the top of your head, but to have an idea where you might find an answer certainly helps.