Create Kirby yaml and content page from string?

I’ve been looking in the cheatsheet to convert a string to a content text file and then save it to a folder. Could be done with PHP but maybe there are simpler ways?

I would like it to work kind of like this if possible

My first text string looks like this (field key text):

**Bold text** This text has the field key "text".

My second text string looks like this (field key email):

**Bold text** This text has the field key "email".

To valid Kirby yaml:

Hopefully there is some function that works like this?

$yaml = stringToPageYaml(array('text' => $text, 'email' => $email));

Save it:

saveToContent($yaml, 'inbox/2016');

Is there a reason why you don’t want to use $pages->create()or $page->create()?

The lack of documentation made me not understand it. It only says “Creates a new page object”.

Then I found this (thanks to you):

Maybe I can use this one. Will try it out. I however don’t understand the difference between the two.

Both return a page object, the only difference is where the page is created, i.e. on the same level or at a subpages level, i.e. if you want to create children of e.g. the blog page, you can use page('blog')->children()->create($parameters)

But see this issue I created yesterday when trying to create pages in a multilang installation.

pages/create worked out of the box. Beautiful!

This must be my lucky day, this time I will only need to create pages in the default language. I’m building a mail storage in the file system.