Page Move not executed in multi language setup


#1

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


#2

Hm, have to look into this, will be on the road now but come back to this later.


#3

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).


#4

Ok, thank you!
I think I can work with this and try a few things. :slight_smile:


#5

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.


#6

Thank you!
Seems to work on my side as well.