Reference

Guide

$files->limit()

Returns a new object with a limited number of elements

$files->limit(int $limit): Kirby\Toolkit\Collection

Parameters

Name Type Default Description
$limit int

The number of elements to return

Return type

Kirby\Toolkit\Collection

Example

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

Inherited from

Kirby\Toolkit\Collection

Source code

kirby/src/Toolkit/Collection.php#L632