Reference

Guide

$files->not()

Returns a Collection without the given element(s)

$files->not(mixed $keys = null): Kirby\Cms\Collection

Parameters

Name Type Default Description
$keys mixed null

any number of keys, passed as individual arguments

Return type

Kirby\Cms\Collection

Example

<ul>
  <?php foreach($page->files()->not($page->files()->first()) as $file): ?>
  <li>
    <a href="<?= $file->url() ?>">
      <?= html($file->filename()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Array of ids, collections or objects as argument

Since 3.4.3

You can also use an array of ids, collections or objects or a mixture of them to exclude from a collection:

An array of ids

$files = $page->images->>not(['image-a.jpg', 'image-b.jpg']);

An array of objects

$files = $page->images()->not([image('image-a.jpg'), image('image-b.jpg')]);

An array of mixed values

$files = $page->files()->not([$page->files()->template('cover'), image('image-a.jpg'), 'image-b.jpg']);

Inherited from

Kirby\Cms\Collection

Source code

kirby/src/Cms/Collection.php#L204