A
A
Anton2016-08-18 11:32:09
Yii
Anton, 2016-08-18 11:32:09

How to redefine the data in the model in different languages?

How in Yii in the model to override the data that is returned, for example, through findAll ()?
I want to implement multilingualism, the language is selected depending on which subdomain you have entered. There are no difficulties in this. I store the language versions of the data in a separate table, but not all the data, but only the content. Therefore, in different languages, I want to replace only the content itself, without affecting other data.
For example, the model has the following fields:
id
category
name
description
In the language table, I store:
item_id
language_id
name
description
I.e. when requesting for the EN language, I would like to receive data from the model for this record with the replaced content of the EN version.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-08-18
@conturov

The afterFind() method is called automatically when populating the AR model with data retrieved from the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question