Blueprint processing functions

So I’m developing a plugin that will allow a person to generate a <form> using the standard blueprint structure, but inside a textarea field (so it’s an extension of kirbytext). Let’s say I’ve developed the code to extract the following from the content

  callback: registration
  success: You rock!
      label: First Name
      type: text
      required: true
      label: Last Name
      type: text
      required: true
      label: Email
      type: email
      required: true
      label: Phone
      type: tel

My question is this: Is there a function in the Kirby toolkit that can convert the above structure (the structure of blueprints) into an array or object, so I don’t have to write my own parsing function? Because that would turn a 12 hour project into 1.

Have you tried this?

This created an array for me, copy pasted from a blueprint…

$str = '
title: Page
pages: true
files: true
    label: Title
    type:  text
    label: Text
    type:  textarea';
print_r( yaml($str) );


    [title] => Page
    [pages] => 1
    [files] => 1
    [fields] => Array
            [title] => Array
                    [label] => Title
                    [type] => text

            [text] => Array
                    [label] => Text
                    [type] => textarea



Thanks! I didn’t realize blueprints were YAML. I guess I didn’t even know what YAML was until using Kirby.

Would be great if you could share your results. I’m really interested in this as you can read here :smile:

It’s getting somewhere. Have to launch a site this week so I’m not spending a lot of time making sure my code is public-ready, but I’ll throw it in Github soon.

1 Like