Header image

Symfony Finland
Random things on PHP, Symfony and web development

Update or create multiple languages at once using eZ Platform PHP API

It is possible to create or update content in multiple languages at once. There is one restriction: only one language can be set a version's language. This language is the one that will get a flag in the back office. However, you can set values in other languages for your attributes, using the setField method's third argument.

update multiple languages
// set one language for new version
$contentUpdateStruct->initialLanguageCode = 'fre-FR';
 
$contentUpdateStruct->setField( 'title', $newgermantitle, 'ger-DE' );
$contentUpdateStruct->setField( 'body', $newgermanbody, 'ger-DE' );
 
$contentUpdateStruct->setField( 'title', $newfrenchtitle );
$contentUpdateStruct->setField( 'body', $newfrenchbody );

This also works when creating new content with the contentUpdateStruct created with newContentCreateStruct.

Source: https://doc.ez.no/display/EZP/3.+Managing+Content


Written by Jani Tarvainen on Thursday May 24, 2018
Permalink -

Leave a comment

comments powered by Disqus

« Migrating eZ Platform Landing Pages and Form Builder Forms -