Create a page which is immediately listed?

Is it possible to create a page via page::create which is immediately ‘listed or public’. No draft? Thanks

If you create a page programmatically, you can publish it right after creating it.

https://getkirby.com/docs/reference/objects/page/change-status

1 Like

i guess you mean with a hook: page.create:after ?

No, I didn’t mean to use a hook, I was assuming your were creating the page programmatically and then you could just add the next step and change its status.

But yes, a hook would work as well.

you mean like this? I will test this once again, but it didn’t work this afternoon.

  $new=$currentpage->createChild([
               'slug'     => 'my-title',
               'template' => 'mytemplate',
               'content' => [
                                       ...
                 ]
   ]); 
   $new->changeStatus("listed");
1 Like

That’s what I meant. Make use that changing the status of the page is not prohibited in the blueprint.

ok, thanks. Is there a way to disable /hide the green dots in the panel. So the client can’t change the status afterwards?

You could hide them via a stylesheet (in combination with this plugin: https://github.com/mullema/k3-panel-view-extended, that allows you to address specific elements instead of applying it to all pages)

Unfortunately, if you disable changeStatus() in your blueprint, you can’t change the status programmatically, we have to wait for a force option to be implemented in the source.

Here is the relevant ideas entry for tracking: https://github.com/getkirby/ideas/issues/171

The plugin provides a blueprint option for your page, no additional css is required.

options:
  hideStatus: true

The change status dots will be hidden in the top bar for that page and in pages sections which list that page.
In the settings menu it will still be possible to change the status.

thanks, i used the plugin + some additional css stuff in a custom panel-css file.