Jump to content

Creating multilanguage pages via API


rajo
 Share

Recommended Posts

Puzzled!

I'm using the API to create child and grand-children pages in an app with more than one language.  When a new page is created, I expect to see it via the API regardless of the current $user->language.  However, it's not the case.  I see that the pages I save in the API have a status field for the language set to 0.  (e.g.  status = 1, but status1563 = 0), which causes them to not be found when searching in a different languages than the default one.

i.e. 

$page->children()->count()    -------> n

$user->language = <some other language>;

$page->children()->count()    -------> 0

 
This seems very weird to me, in principle.
 
In practice, is there a different way to change the default behaviour of $new_page->save() to set $new_page->status1563 = Page::statusOn ?
 
Thanks.
Merci.
Link to comment
Share on other sites

I think it is still the case that you have to explicitly activate all languages when working with the api. More info and code in this thread.

https://processwire.com/talk/topic/4383-how-to-set-language-active-via-api/

Like apeisa's last question suggests, it might make more sense if all langs would be enabled by default. Dunno if anything has been done about it, via a Github request or the like.

  • Like 3
Link to comment
Share on other sites

  • 10 months later...

Thank you for confirming it's not built-in.  IMO, it should be the default so as to be symmetrical w/ the admin UI. 

Came across this while importimg lots of pages. I agree with rajo, that languages should be activated by default when creating pages via API.

ATM it is not obvious that we have to do it manually. And I just realized it after already having imported some 300 pages :(

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...