<p>The function is</p>

<pre><code>public function getSetByHandle(string $globalSetHandle, int $siteId = null)
</code></pre>

<p>Thus you can grab all the siteIds you want and loop through them</p>

<pre><code>{% for siteId in sites %}
    {% set setForSiteId = craft.app.getGlobals().getSetByHandle('handle', siteId) %} 
{% endfor %} 
</code></pre>

CC BY-SA 4.0
2018-06-01T20:49:55.707Z
Thanks Robin! Just for clarity purposes:

We'd grab all sites with: `{% set sites = craft.app.sites.getAllSites() %}`

And then use the loop you provided as follows:

````
{% for site in sites %}
    {% set siteGlobals = craft.app.getGlobals().getSetByHandle('myGlobalsHandle', site.id) %}
{% endfor %}
````
cballenar
CC BY-SA 4.0
2018-06-01T19:27:45.707Z
2018-06-01T20:50:47.263Z
2018-06-01T20:50:47.263Z
Robin Schambach
<p>How would I get the global variables associated to other sites?</p>

<p>For example, in an instance where I have three websites under the group <code>languages</code> for the English, Spanish, and French versions. I have specified <code>companyInformation</code> globals that contain: phone, address, and logo. </p>

<p>From a template I would like:
- Loop through all sites under the group <code>languages</code>
- Get <code>companyInformation</code> global values for each of the sites</p>

<p>Thanks in advance</p>

<templating><localization><globals><multi-site>
Get globals from other sites
# Get globals from other sites

(Asked by: username_0 on 2018-06-01)

How would I get the global variables associated to other sites?

For example, in an instance where I have three websites under the group `languages` for the English, Spanish, and French versions. I have specified `companyInformation` globals that contain: phone, address, and logo.

From a template I would like:
- Loop through all sites under the group `languages`
- Get `companyInformation` global values for each of the sites

Thanks in advance

**Tags:** templating, localization, globals, multi-site

---

## 1 answers

### Answer by username_1 on 2018-06-01. Score: 3 | Accepted answer

The function is
public function getSetByHandle(string $globalSetHandle, int $siteId = null)

Thus you can grab all the siteIds you want and loop through them
{% for siteId in sites %}
    {% set setForSiteId = craft.app.getGlobals().getSetByHandle('handle', siteId) %} 
{% endfor %}

> **Comments:**
> **username_0**: Thanks Robin! Just for clarity purposes:  We'd grab all sites with: `{% set sites = craft.app.sites.getAllSites() %}`  And then use the loop you provided as follows:  ```` {% for site in sites %}     {% set siteGlobals = craft.app.getGlobals().getSetByHandle('myGlobalsHandle', site.id) %} {% endfor %} ````  

---

