Reference

$pages->not()

Returns a Collection without the given element(s)

$pages->not($keys = null): Collection

Parameters

Name Type Default Description
$keys mixed null

Return type

Collection

Example

<h2>All pages except project-b</h2>
<ul>
  <?php foreach($page->children()->not('project-b') as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= $subpage->title()->html() ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Pass collection as argument

(since 2.3.0+)
You can now pass a collection as argument as well:

<ul>
  <?php
  $excluded = $page->children()->filterBy('template', 'some_template');
  foreach($page->children()->not($excluded) as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= $subpage->title()->html() ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Inherited from

Kirby\Cms\Collection

Source code

kirby/src/Cms/Collection.php#L194