Creating pages without Dialog

Hi there,

i’m working on a Kirby 4 backend for managing date based entries.
So i can print out a pages list in the panel and the pages are sorted by date via:

num: '{{ page.datefield.toDate("Ymd") }}'

in the page blueprint.

Thats works fine. But when i use the add button of the pages section, the typical dialog appears and wants me to enter a title and a slug. But the entries have no titles, the slug should be a random id.

My first approach was to use the Janitor plugin and add a custom create button next to the list, to set up a page with current date and random slug with php. But janitor needs the kirby CLI and i have no idea how i could manage to install it on a shared webspace.

What would be the best approach to solve my problem?

Ok, so i found a solution to edit the page create dialog for every template listed in $templates:

Kirby::plugin('xyz', [
  'areas' => [
    'site' => function ($kirby) use ($templates) {
      return [
        'dialogs' => [
          'page.create' => [
            'load' => function () use ($kirby, $templates) {
              $dialog = $kirby->core()->area('site')['dialogs']['page.create']['load']();
              $template = $dialog['props']['blueprints'][0]['name'];

              if (in_array($template, $templates)) {
                $dialog['props']['fields']['title']['hidden'] = True;
                $dialog['props']['fields']['slug']['type'] = "text";
                $dialog['props']['fields']['slug']['hidden'] = True;
  
                $dialog['props']['value']['title'] = $dialog['props']['blueprints'][0]['title'];
                $dialog['props']['value']['slug'] = uniqid();
              }

              return $dialog;
            }
          ],
        ]
      ];
    },
  ]
]);

This does the job for creating a page with random slug and static title, the dialog now only shows the date field by adding to the page blueprint:

create:
	fields:
		- date


Next step is the duplicate dialog, so i did the same for page.duplicate but with:

'page.duplicate' => [
  'load' => function ($id) use ($kirby, $templates) {
    $dialog = $kirby->core()->area('site')['dialogs']['page.duplicate']['load']($id);

which works, but of course the date field is missing now, so how could i add that?

My first approach was with:

$page = Find::page($id);
$dialog['props']['fields']['date'] = $page->blueprint()->field('date');

but this adds an invalid date field to the dialog :man_shrugging:

Thank you for any ideas!

So now in 4.1.0 my page creation problem is solved :partying_face:
Great feature! :clap:

BUT duplicating is still a problem :frowning:

create:
  slug: "{{ site.uid }}"

Still shows me the slug field in the duplicate dialog.
Is this a bug or on purpose?

Probably neither, but just not implemented.

Kirby by default adds an appendix (‘copy’), so the dialog gives you a chance to amend it. Of course, this is not useful if the slug should be created automatically.

You could probably overwrite the duplicate dialog, if you can’t wait until this might get implemented. Don’t know if there is a feature request yet.