Skip to content

Kirby 4.1.2

$page->files()

Returns the Files collection

$page->files(): Kirby\Cms\Files

Return type

Kirby\Cms\Files

Parent class

Kirby\Cms\Page

Example

<h2>Files</h2>
<ul>
  <?php foreach($page->files() as $file): ?>
  <li>
    <a href="<?= $file->url() ?>">
      <?= $file->filename() ?>
      (<?= $file->niceSize() ?>)
    </a>
  </li>
  <?php endforeach ?>
</ul>

Note that the default sorting order of files is according to their order in the file system. To sort files by their manual sorting order, you can use $files->sortBy('sort'), where sort is the field that stores the sorting number if you manually sort files in the Panel.