Reference

Guide

$files->slice()

Returns a slice of the object

$files->slice(int $offset = 0, int $limit = null): Kirby\Toolkit\Collection

Parameters

Name Type Default Description
$offset int

The optional index to start the slice from

$limit int null

The optional number of elements to return

Return type

Kirby\Toolkit\Collection

Example

<ul>
  <?php foreach($page->files()->slice(5,10) 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#L835