Model not defined on page create in multi language setup

Hi,

I openend a GitHub issue concerning page->create() in multi language setup:

Can anyone confirm this bug? Is there a workaround for it?
I tried writing a custom create function but this would lead to a lot of code duplication from the Kirby core since the original function uses some protected methods inside the Page class.

Thank you,
Georg

What exactly is the undesired effect of this? What do you expect and what do you get instead?

The issue is that the page models are not applied that way.
My template is wrongly called myTemplateEnbut isset(static::$models[$template]) is looking for myTemplate. With that I’m not getting a MyTemplatePage object in return but a DefaultPage.

This leads to unwanted effects if I continue to work with the returned page. For instance if I do a $page->update() it will create a default.en.txt. file with the updated content next to the original file with the correct template.
Also $page->intendedTemplate() seems to refer to default instead of mytemplate.

Does this make sense?

I see the problem with the create method being unable to find the correct page model, but I can’t reproduce how that creates wrong text files.

I can be totally wrong, but AFAIK a model isn’t used for _creating _ pages? :thinking:

1 Like

Well, the model is not really used. for creating the page, but it is “assigned” to the page after creation. And I assume. that if you want to use a page model on the newly created page it would then fail.

1 Like

@georgobermayr Could you post the code that is failing?

Sorry, I did some more testing now: Turns out I can’t reproduce the issue either with the Plainkit.
As far as I can tell it seems to be related with a helper function we created that loads Page models from an array defined in a plugin. I don’t know how this is related but I think we can take debugging from here …
Thank you!