Hi,
I’m having issues with $page->move()
in a multi language setup:
kirby()->hook('panel.page.create', function($page, $oldPage = null) {
$page->move('newslug');
});
This works fine if I create a new page in the default language of the site. The page is moved as it should. If I switch to a different language in the panel and create a new site however nothing happens. There are also no exceptions from the move function. It seems as if the function is not called at all.
Is this a bug?
Kind regards,
Georg
Hm, have to look into this, will be on the road now but come back to this later.
1 Like
Sorry, I’m late, almost forgot about this open topic because of other stuff.
I can confirm this doesn’t work, but that is probably intended behaviour, because the UID of a page is defined by the default language page. If you really need this, you could probably use a toolkit method instead, i.e. dir::move()
instead of $page->move()
.
Just on a side note, the panel.page.create
hook only takes one parameter, no $oldpage
(but that is not connected to the current problem).
Ok, thank you!
I think I can work with this and try a few things. 
I tested something, and came up with this:
kirby()->hook('panel.page.create', function($page) {
$lang = $page->content()->language();
$page = page($page->uri());
$page->move('newslug');
$uri = $page->uri();
$page->update([
], $lang);
$this->panel()->redirect('pages' . DS . $uri . DS . 'edit');
});
Looks a bit ugly but seems to work.
Thank you!
Seems to work on my side as well.