Page create with support for lang attribute

https://getkirby.com/docs/cheatsheet/page/create
https://getkirby.com/docs/cheatsheet/page/update

Maybe I want to create a de page instead of the default en. Then I need to first create an empty page and then use $page->update() to have the de version.

It would be nice to have a lang attribute in the create function as well. What do you think?

Update

Now I need to do something like this:

page()->create($uri, 'template', array() );
page($uri, site()->language()->code() );

But I think this would be nicer:

page()->create($uri, 'template', array(), site()->language()->code() );

I think it’s intended that the default language needs to be created first because of Kirby’s fallback to the default language if the others don’t exist. It could be quite a mess if there was a way to create pages in a secondary language only.

1 Like

Hm, you can, however, create a non-default language page via the panel. The panel then automatically creates the page in the default language.

I think, such an automatism could also be implemented for the create() method?

3 Likes

Yes, I agree, that would be solid I think! :slight_smile:

1 Like