Skip to content

Kirby 3.9.8

$field->toObject()

Parse yaml data and convert it to a content object

$field->toObject(): Kirby\Cms\Content

Return type

Kirby\Cms\Content

Example

This field method is intended for converting an object field to a content object.

<?php if ($contact = $page->contact()->toObject()): ?>
<dl>
  <dt><?= Str::ucfirst($contact->photo()->key()) ?></dt>
  <dd><?= $contact->photo()?->toFile()->crop(200) ?></dd>
  <dt><?= Str::ucfirst($contact->name()->key()) ?></dt>
  <dd><?= $contact->name() ?></dd>
  <dt><?= Str::ucfirst($contact->email()->key()) ?></dt>
  <dd><?= $contact->email() ?></dd>
  <dt><?= Str::ucfirst($contact->phone()->key()) ?></dt>
  <dd><?= $contact->phone() ?></dd>
</dl>
<?php endif ?>