Converts a yaml field to a Structure object

  • return ($structure)

While the yaml method returns a simple associative PHP array for structured field content, the toStructure method gives you a full blown Kirby Collection which makes it possible to use Kirby's chaining syntax.


Text file

title: My page
- name: Twitter
  url: http://twitter.com/getkirby
- name: Github
  url: http://github.com/getkirby


<h1>On the web</h1>
  <?php foreach($page->accounts()->toStructure() as $account): ?>
    <a href="<?= $account->url() ?>">
      <?= $account->name()->html() ?>
  <?php endforeach ?>

Is something missing or incorrect? Edit this page on Github…