$page->file($filename = false)

Returns a specific $file object within the page's directory by filename. If no filename is given, the first file will be returned

  • $filename (string)
    Optional, a filename
  • return ($file)

Example

Fetching the first file

<?php if($file = $page->file()): ?>
<a href="<?= $file->url() ?>">
  <?= html($file->filename()) ?>
</a>
<?php endif ?>

Fetching a specific file

<?php if($file = $page->file('myfile.pdf')): ?>
<a href="<?= $file->url() ?>">
  <?= html($file->filename()) ?>
</a>
<?php endif ?>