Hey there,
I’m trying to save parts of my site to a SQLite database, so obviously I read both of the cookbook articles (Using databases | Kirby CMS and Content from a database | Kirby CMS). Unfortunately neither one goes into detail on how to write back more complex content than text/numbers/booleans.
So if I want to write the value of a “reference” field (e.g. a file, an image, a page, etc.) to my database, I obviously have to implement the writeContent
function in my model.
writeContent
receives a $data
parameter. However, the value of all reference fields is not an array of all the referenced UUIDs (which I would have expected), but instead it’s a multiline YAML string.
So, I’m getting something like this:
(
[invnum] => 701
[registered] => 2024-05-12
[manufacturer] => 3D-Druck
[price] => 16
[images] => - file://eNIhk6X0G3NN0W0d
- file://1qUsdFpHdgUJK0um
- file://EWuxHTYJGql0LXcE
)
And this is what I would expect/would love to have:
(
[invnum] => 701
[registered] => 2024-05-12
[manufacturer] => 3D-Druck
[price] => 16
[images] => ["file://eNIhk6X0G3NN0W0d", "file://1qUsdFpHdgUJK0um", "file://EWuxHTYJGql0LXcE"]
)
Now do I really need to manually split/format this string into an Array myself? Or are there any helpers, flags or other methods I can use, to get an actual Array here?
Is this an intentional design decision to already use YAML values here in the model?