$page->document($filename = false)

Returns a specific document $file object by filename. If no filename is given, the first available document will be returned.

  • since: Kirby 2.3.0
  • $filename (string)
    Optional, a filename
  • return ($file)

Example

Fetching the first document

<?php if($document = $page->document()): ?>
<a href="<?= $document->url() ?>" download>Download</a>
<?php endif ?>

Fetching a specific document

<?php if($document = $page->document('cv.pdf')): ?>
<a href="<?= $document->url() ?>" download>Download</a>
<?php endif ?>