Skip to content

Kirby 5.0.4

$field->toPage()

Returns a page object from a page id in the field

$field->toPage(): Kirby\Cms\Page|null

Return types

Kirby\Cms\Pageornull

This method modifies the existing $field object it is applied to and returns it again.

Examples

<?php if ($related = $page->related()->toPage()): ?>
  <p><a href="<?= $related->url() ?>">Read more…</a></p>
<?php endif ?>