Kirby Props Helper

Helper for converting arrays to Kirby content objects. Particularly useful for passing data into snippets, unlocking Kirby field methods on your snippet data (no more isset and etc):

Example:

# Pass props
snippet('some-snippet', kprops([
  'text' => 'Here *is* some **text**',
  'image' => 'filename.jpg',
  'page' => 'some/page'
]));

# Access in `some-snippet`
<?= $props->text()->kirbytext() ?>
<?= $props->image()->toFile()->url() ?>
<?= $props->page()->toPage()->url() ?>
1 Like