Reference

Guide

$pages->find()

Find one or multiple elements by id

$pages->find(string $keys = null): mixed

Parameters

Name Type Default Description
$keys string null

Return type

mixed

Example

Fetch a single subpage

<?= $page->children()->find('subpage-a')->title() ?>

Fetch multiple subpages

<ul>
  <?php foreach($page->children()->find('subpage-a', 'subpage-c', 'subpage-i') as $subpage): ?>
  <li>
    <a href="<?= $subpage->url() ?>">
      <?= html($subpage->title()) ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Inherited from

Kirby\Toolkit\Collection

Source code

kirby/src/Toolkit/Collection.php#L345