Reference

$files->find()

Find one or multiple elements by id

$files->find(string $keys = null): mixed

Parameters

Name Type Default Description
$keys string null

Return type

mixed

Example

Fetch a single file

if($file = $page->files()->find('myfile.pdf')):
  echo $file->url();
endif;

Fetch multiple files

<ul>
  <?php foreach($page->files()->find('document-a.pdf', 'document-b.pdf', 'document-c.pdf') as $file): ?>
  <li>
    <a href="<?= $file->url() ?>">
      <?= $file->filename()->html() ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Source code

kirby/src/Toolkit/Collection.php#L340