Skip to content

Kirby 4.5.0

$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

Parent class

Kirby\Cms\Files inherited from 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

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