Localized Fields (since 1.3.2)

Skip to end of metadata
Go to start of metadata

The datatype "Localized Fields" is a container which can be filled with selected datatypes and layouts. The advantage of this is to make it very easy to translate fields to the configured languages.

Define your localized fields

First of all you have to configure your localized fields and layouts, this can be simply done in the class editor.

If not already configured, please specify the valid languages for your website. You can do this in Settings -> System -> Website

Then the result in your object editor will look like this: 

Now pimcore generates automatically the input widgets for every configured language, which are separeted using tabs.

Accessing the data

Accessing the data is very easy: 

// with global registered locale

$object = Object_Abstract::getById(234);
$object->getName(); // will return the en_US data for the field "name"




// get specific localized data, regardless which locale is globally registerd

$object->getName("de") // will return the german value

Setting data

is as simple as getting the data:

$object = Object_Abstract::getById(234);
$object->setName("My Name", "fr") // set the french value for the field name
WARNING
Please note that moving a field from outside (normal object field) into the localizedfield container means the loss of data from the field in all objects using this class.

Inheritance

WARNING
Is not possible with this datatype.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.