1

I have a localized, two language site (en and fr) that I have a translated global variable set for. My question is: is there a way on a Craft 3 template to directly access a translation of a variable that isn't the same as the currentSite language. Specifically, I'd like to show both translations of the same variable on one page.

I am getting the variable with this currently: siteOwnerInfo.siteOwner

1

Take a look at the Craft docs page for "Globals" under Querying Globals.

You can pass a site ID number to an element query to get globals from another site/language. For example, if your French site id number is 2, you could do this:

{% set siteOwnerInfoFrench = craft.globalSets()
  .handle('siteOwnerInfo')
  .siteId(2).one() %}

{{ siteOwnerInfoFrench.siteOwner }}
1
  • This worked perfectly. Thank you for the assist! Feb 11 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.