I’m updating some file metadata using the update
method:
$page->file('some-file.jpg')->update(array( 'some_field' => 'new value');
When using the panel on a multilingual website metadata files are created for each language (e.g. some-file.jpg.en.txt
, some-file.jpg.fr.txt
, …).
The update method updates the “default” metadata file some-file.jpg.txt
but doesn’t seem to be able to update the language files.
Is this a Kirby limitation or am I missing something?
You need to pass which language you want to update:
$page->file('some-file.jpg')->update(array(
'some_field' => 'new value'
), 'en');
You can also let it use the current language:
$page->file('some-file.jpg')->update(array(
'some_field' => 'new value'
), site()->language()->code());
1 Like
Awesome! Works perfectly. Thank you very much.
The docs doesn’t mention that second argument though.
But this second argument is missing in the docs at http://getkirby.com/docs/cheatsheet/page/update too…
texnixe
6
Thanks, I’ve just updated it.
Edit: there’s probably more multi-lang site specific stuff we need to add, we have that on the list.
1 Like