Hi,
I have to change the slug in page.create:after
hook.
For testing purposes, the hook is very simple:
'hooks' => [
'page.create:after' => function ($page) {
$page->changeSlug("ma-new-slug");
}
]
After adding a new page (slug set to my-old-slug
), the hook is executed and the slug is changed. But the response send back to the panel does not reflect the changed slug:
Any ideas to get around this?
moeli
February 15, 2019, 7:37am
2
a custom page create method as suggested Here by @lukaskleinschmidt worked for me.
1 Like
Great, thanks to you both, @lukaskleinschmidt and @moeli .
Oli1
March 7, 2019, 2:50pm
4
Has anybody a “real world” example how to include this? My tryouts failed and I wanted to do exactly the same …
'hooks' => [
'page.create:after' => function($page) {
if ( str::startsWith($page->intendedTemplate(), 'block-' ) ) {
$page->changeSlug('xxxxx');
}
}
]
Always returns in errors …
1 Like