Skip to content

Kirby 4.3.0


Returns a Collection without the given element(s)

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


Name Type Default Description
... $keys mixed null any number of keys, passed as individual arguments

Return type


Parent class

Kirby\Cms\Files inherited from Kirby\Cms\Collection


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

Array of ids, collections or objects as argument

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']);