Hi
I’ve created content from .CSV file with bunch of entries. It worked as expected. Now I would like to turn these virtual pages to real content pages, editable from the panel.
I could read from the merging content sources article :
We will extend the Content from a spreadsheet example with content we actually add in the
content
folder, let’s say because we want to add an image to each each animal and some additional content.
Cool, this is exactly my purpose !
To this end, we add new subpages to the
/animals
parent page, using the same slugs that we generated in theanimals.php
model.
Ouch ! I have more than 500 entries…Is there a method to create these folders (with .txt inside) automatically from these virtual pages?
This is my model file, very similar to the example from the doc :
<?php
class CollectionPage extends Page
{
public function children()
{
$csv = csv($this->root() . '/collection.csv', ';');
$children = array_map(function ($oeuvre) {
return [
'slug' => Str::slug($oeuvre['auteur']),
'template' => 'oeuvre',
'model' => 'oeuvre',
'num' => 0,
'content' => [
'auteur' => $oeuvre['auteur'],
'titre' => $oeuvre['titre'],
'date' => $oeuvre['date'],
'medium' => $oeuvre['medium'],
'edition' => $oeuvre['edition'],
'format' => $oeuvre['format'],
'galerie' => $oeuvre['galerie'],
'certificat' => $oeuvre['certificat'],
'prix' => $oeuvre['prix'],
'stockage' => $oeuvre['stockage'],
'exposition' => $oeuvre['exposition'],
]
];
}, $csv);
return Pages::factory($children, $this);
}
}