Creating virtual pages from a db creates folders in content

Hi,

I’m following this tutorial to create some virtual pages from my database. I’m generating a uuid so I was expecting Kirby not to generate content folders, but somehow it is.

Am I missing something here?

<?php

use Kirby\Uuid\Uuid;

class OrdersPage extends Kirby\Cms\Page
{
  public function children(): Pages
  {
    if ($this->children instanceof Pages) {
      return $this->children;
    }

    $orders = [];

    foreach (Db::select('orders') as $order) {
      $orders[] = [
        'slug'     => $order->orderid(),
        'template' => 'order',
        'model'    => 'order',
        'content'  => [
          'orderid'  => $order->orderid(),
          'uuid'  => Uuid::generate(),
        ]
      ];
    }

    return $this->children = Pages::factory($orders, $this);
  }
}

The problem was that I had multiple languages set up for my website and I needed to specificially add a ‘translations’ property like so:

$orders[] = [
        'slug'     => $order->orderid(),
        'template' => 'order',
        'model'    => 'order',
        'listed'   => false,
        'translations' => [
          'de' => [
            'code' => 'de',
            'content' => [
              'orderid'  => $order->orderid(),
              'uuid'  => Uuid::generate(),
            ],
          ],
          'en' => [
            'code' => 'en',
            'content' => [
              'uuid'  => Uuid::generate(),
            ],
          ],
        ]
      ];
2 Likes