Following the programmable blueprint tutorial, this is what i’ve have right now:
<?php
$defaultArray = [];
$collection = site()->index()->filterBy('template', 'default');
$default = '';
foreach($collection as $page){
$default = ' - ' . $page;
}
// it does not work with an array
// $default = [];
// foreach($collection as $page){
// $default[] = ' - ' . $page;
// }
// create the array for the page blueprint with two columns
$yaml = [
'title' => 'Porfolio maker1',
'columns' => [
'main' => [
'width' => '2/3',
'sections' => [
'fields' => [
'type' => 'fields',
'fields' => [
'toInclude' => [
'label' => 'Pages to include',
'type' => 'pages',
'default' => $default
]
]
]
], // dynamically generated sections from above
]
]
];
return $yaml;
The code works with a single string, but not with an array of strings, which is the whole point. What syntax should I use to generate the correct yaml from the php array ? i’m not used to working with yaml