I’m using a custom plugin for custom metadata field. When I try to edit the field in metadata modal, the field of the language other than the current active language is empty. I would like to modify the code so it shows values of all supported languages in their corresponding fields.
The edit function of the plugin contains the following code:
$additional=$metadatafieldDAO->getAdditionalFieldValue($articleId, ‘additional’);
$templateMgr->assign(‘additional’,$additional);
It is easy to modify the getAdditionalFieldValue function to return the values in all supported languages, but I don't know how to assign these values to the field and display them.
Following is the template for the additional metadata field:
{fbvFormSection label="plugins.generic.articleMetadata.additional" }
{fbvElement type="textarea" rich="extended" multilingual=true name="additional" id="additional" value=$additional }
{/fbvFormSection}
I just found the answer after some search and experimenting.
So, a multilingual field can be updated by simply passing an associative array to the function $templateMgr->assign()
.
The array takes the form $array[$locale]=$value_for_that_locale
. For example:
$additional[‘en_US’]=“additional metadata”;
$additional[‘ar_IQ’]=“بيانات وصفية اضافية”;
$templateMgr->assign(‘additional’,$additional);