CSV, correct class extension naming?

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é

The class name must be the same as the blueprint/template name (in your case without the dash). Or you have to rename the template/blueprint to client.php/client.txt

Hello

Many thanks for your prompt response. Honestly I did not understand your explantions with the “slash” :upside_down_face:.

But finally I managed to get it work:

I renamed the model file again to:

/site/models/clients-default.php

and the class in it again to:

... class ClientsDefaultPage extends Page ...

and also renamed the template file name to:

/site/templates/clients-default.php

seems that on my previouse attempts I introduced to much different naming combinations and I missed the correct one :roll_eyes:

thanks again and best regards,

André

Because it should’ve been dash :see_no_evil: