Create posting with a preset title

Is it possible that when creating a new page, the title is preset with an arbitrary and variable value (e.g. the Unix timestamp)? Is there a plugin or a workaround for this?

Background: I want to publish articles via the panel that basically do not need a title. For this reason I want to do this unnecessary work step automatically by inserting a unique value so that it is stored properly in the system.

Yes, via a plugin, check out https://github.com/lukaskleinschmidt/kirby-custom-add-form

Thanks for your quick reply, dear @texnixe. But: Sorry, no changes. What I have done:

  1. downloaded the plugin
  2. unzipped it
  3. uploaded it to my webspace to the folder site/plugins/
  4. renamed the folder to custom-add-form
  5. Changed [template-name] on line 13 to article in the custom-add-form.php file. (Because I want to use the mechanism for the template, that is defined under site/templates/article.php )

Nothing happens. It seems, that the manual is to short for me.`Am I missing or misunderstanding something here?

You have to adapt it to your purposes, I just wanted to show you a way to have a custom add form. It doesn’t do what you want out of the box.

Since I had no idea where and how I should adapt something for my purposes, I experimented a little and found the solution.

(1) In the file site/plugins/custom-add-form/custom-add-form.php you don’t have to enter the name of the template you want to use (= the name of the file in site/templates/) in line 13, but the name of the controller (= the name of the file in site/controllers/). In my case: blog.

(2) In the file site/plugins/custom-add-form/form.php I have defined how the default string should look like, which should also result in the folder name in the file system: $timestamp = "posting_".time();

(Note: I have noticed that URLs starting with a digit are a problem for kirby. The visible/invisible mode seems to react unclearly. Therefore, it is better to start them with a letter.)

(3) The variable $timestamp is then inserted into the definition of the form in the file form.php:

$form = new Kirby\Panel\Form(array(
'title' => array(
  'label'        => 'pages.add.title.label',
  'type'         => 'title',
  'placeholder'  => 'pages.add.title.placeholder',
  'autocomplete' => false,
  'autofocus'    => true,
  'required'     => true,
  'default'	 => $timestamp, // my modification
),
'uid' => array(
  'label'        => 'pages.add.url.label',
  'type'         => 'text',
  'icon'         => 'chain',
  'autocomplete' => false,
  'required'     => true,
  'default'	 => $timestamp, // my modification
),
'template' => array(
  'label'    => 'pages.add.template.label',
  'type'     => 'select',
  'options'  => $options,
  'default'  => key($options),
  'required' => true,
  'readonly' => count($options) == 1 ? true : false,
  'icon'     => count($options) == 1 ? $page->blueprint()->pages()->template()->first()->icon() : 'chevron-down',
)
));

If I create a new post now, the fields “Title” and “URL Attachment” (“URL-Anhang” in german) are filled with a dynamic text like “posting_1544808908” and I don’t have to worry about it anymore.

Thanks to @texnixe for the hint and @lukaskleinschmidt for the plugin! May this be helpful to all those like me who have no idea of controllers, hooks, templates and all the yaddayadda that others seem to take for granted.

UIDs consisting of just a number, like 1984 or a Unix timestamp, are no problem at all. The problem are titles like “10 reasons to …”, which are converted to a UID `10-reasons-to-", where the number is then regarded as a visibility flag.