Hello
I have followed the guide for CSV virtual page creation and also the Page Models guide for correct class naming. Nevertheless the page class extention for the function ->children() is not called. My structure for the CSV integration is the following:
/content/0_projects/0_clients/clients-default.de.txt
/content/0_projects/0_clients/clients-default.de.csv
/site/templates/clients-default.php
/site/models/clients.php
The following is actually working:
- template “clients-default.php” renders titel and text from “clients-default.de.txt” but not the part for CSV children rendering
- dump (in above template) of CSV shows correct parsing to array returned by csv function (in /site/plugins/helpers/index.php) called within the template “$csv = csv($page->root() . ‘/clients-default.de.csv’, ‘;’);”
- dump (in above tempalte) of $page shows for [children] an empty object
I have tried the following:
- renaming /site/models/clients.php to /site/models/clients-default.php without any change
- renaming class from “ClientsPage” to “ClientsDefaultPage” without any change
- inserting in the class for children function a dummy children array without any change
actually my /site/models/clients.php has the following code:
<?php
class ClientsPage extends Page
{
public function children()
{
$csv = csv($this->root() . '/clients-default.de.csv', ';');
$children = array_map(function ($client) {
return [
'slug' => Str::slug($client['id']),
'template' => 'clients-default',
'model' => 'clients',
'num' => 0,
'content' => [
'id' => $client['id'],
'visible' => $client['visible'],
'state' => $client['state'],
'city' => $client['city'],
'name' => $client['name'],
'type' => $client['type'],
]
];
}, $csv);
$children = [
'slug' => Str::slug('test_id'),
'template' => 'clients-default',
'model' => 'clients',
'num' => 0,
'content' => [
'id' => 'test_id',
'visible' => 'test_visible',
'state' => 'test_state',
'city' => 'test_city',
'name' => 'test_name',
'type' => 'test_type',
]
];
return Pages::factory($children, $this);
}
}
?>
I would be very grateful for any hint what is wrong with extending class naming.
best regards,
André
.