Additional translation method support for relational fields #14929
-
It'd be great if relational fields (assets, entries and categories) supported all the same translation methods/capabilities as other fields. Some context: I'm currently working on a multi-site Craft 5 build, which leans pretty hard into site groups for its content model and general structure. In total there are 5 site groups, each representing a different "sub-brand". Each group contains 3 sites, in different languages. In a few spots, the fact that there is no "Manage relations on a per-site group basis" has been something we've had to work around. Having something like that and "Manage relations on a per-language basis", echoing the translation methods available to content table fields, would be brilliant. As an aside: just to see what would happen, I actually tested overriding an asset fields' use craft\fields\Assets;
Event::on(
Assets::class,
Assets::EVENT_DEFINE_BEHAVIORS,
static function (Event $event) {
/** @var Assets $field */
$field = $event->sender;
if ($field->handle === 'heroImage') {
$field->translationMethod = Field::TRANSLATION_METHOD_SITE_GROUP;
}
}
); ...to my surprise, this actually appears to work 😮 I might be overlooking some unfortunate side effects, though. But, in lieu of proper support for something similar, are there any compelling arguments for not leaving that hack in? 😇 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Closing this as a duplicate of #8539. But it’s coming in 5.3 (#15400) 🎉 |
Beta Was this translation helpful? Give feedback.
Closing this as a duplicate of #8539. But it’s coming in 5.3 (#15400) 🎉