For my form plugin I'm using a global set of fields. These can be set in 2 languages default
and en
.
Problem is whenever I try to output them I cant dynamically make them use the current site locale/multi-site.
This is the current code:
$localeHandle = Craft::$app->getSites()->getCurrentSite()->handle;
// form texts
$entries = GlobalSet::find()
->siteId('*')
->site($localeHandle)
->handle('popupContact')
->asArray()
->one();
If $localeHandle
is set to either default
or en
it works. I cant figure out how to get the handle though. Documentation doesn't state anything either.
Edit:
Craft::$app->getSites()->getCurrentSite()->handle;
returns the default site handle.