Related to :
Hello,
how can I set the default status of a new page or content to “listed” instead of “draft”?
I’m using Kirby 3.
Thanks
I have a hook (inside a plugin) that put my pages on ‘listed’ automatically but something weird happens on some of them (in nested pages usually) : it keeps the draft page and then conflicts with the listed one.
'hooks' => [
'page.create:after' => function ($page) {
$page->changeStatus('listed');
}
]
Here is a video to explain:
ARe there any other hooks that might interfere?
I think there is another option to force listed pages that is probably more reliable: overriding the create()
page method in a model.
Actually, I think you are right.
I feel like it comes from another hook in the AutoID plugin from @bnomei
After commenting this line it works again :
if ($page) {
return \go($page->url(), 302);
}
return \go(site()->errorPage()->url(), 404);
},
],
];
},
'hooks' => [
'page.create:after' => function ($page) {
\Bnomei\AutoID::push($page);
},
'page.update:after' => function ($newPage, $oldPage) {
\Bnomei\AutoID::remove($oldPage);
\Bnomei\AutoID::push($newPage);
},
'page.duplicate:after' => function ($duplicatePage) {
\Bnomei\AutoID::push($duplicatePage, true);
},
'page.changeNum:after' => function ($newPage, $oldPage) {
\Bnomei\AutoID::remove($oldPage, true);
Then instead of fiddling with the AutoID plugin, I’d consider the alternative method.
Yes, I’ll have a look at this. Thanks again.
texnixe
September 18, 2020, 4:45pm
8
Let us know if and when you need further details. but should be rather straightforward.