Craft CMS Asked by Stabilimenta on June 17, 2021
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
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 }}
Correct answer by Alex Roper on June 17, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP