<p>Not sure why you're referencing "entry" in your code, I'd think the code should be:</p>

<pre><code>{% for block in footer.links %}
  {% if block.navigationLinks | length %}
    &lt;h3&gt;{{ block.navigationHeadline }}&lt;/h3&gt;
    {# Show the navigationHeadline if it has links #}
    &lt;ul&gt;
      {% for row in block.navigationLinks %}
        &lt;li&gt;{{ row.linkLabel }} - {{ row.linkUrl }}&lt;/li&gt;
      {% endfor %}
    &lt;/ul&gt;
  {% endif %}
{% endfor %}
</code></pre>

<p>So, "links" is the matrix on your "footer" global, which you can access from anywhere. You loop over that, get a block for each matrix block, and access "navigationHeadline" and "navigationLinks" through that.</p>

CC BY-SA 3.0
2015-03-17T22:08:15.930Z
2015-03-17T22:08:15.930Z
André Elvan
<p>I have created a Global with the handle 'footer', which contains a Matrix field 'links' and I'm trying to get this into a template, but I can't seem to get this to work.</p>

<p>The 'links' Matrix contains a Block Type 'navigation' with a Plain Text field 'navigationHeadline' and a Table field 'navigationLinks'. The table field contains 'linkLabel' and 'linkUrl' columns (see attached image).</p>

<p>I'm ultimately creating my navigation in a Global with a Headline and some Links and the Headline should only appear if each block has some links;</p>

<pre><code>{% for block in entry.links %}
    {% if entry.navigationLinks | length %}
        &lt;h3&gt;{{ block.navigationHeadline }}&lt;/h3&gt;
        {# Show the navigationHeadline if it has links #}
        &lt;ul&gt;
            {% for row in entry.navigationLinks %}
                &lt;li&gt;{{ row.linkLabel }} - {{ row.linkUrl }}&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;
    {% endif %}
{% endfor %}
</code></pre>

<p>I wondered if anyone can help me resolve my obvious errors. Thanks.</p>

<p><img src="https://i.sstatic.net/OoNwe.png" alt="Screenshot of Global"></p>

<matrix><globals><table-field>
Accessing a Matrix field in a Global
# Accessing a Matrix field in a Global

(Asked by: username_0 on 2015-03-17)

I have created a Global with the handle 'footer', which contains a Matrix field 'links' and I'm trying to get this into a template, but I can't seem to get this to work.
The 'links' Matrix contains a Block Type 'navigation' with a Plain Text field 'navigationHeadline' and a Table field 'navigationLinks'. The table field contains 'linkLabel' and 'linkUrl' columns (see attached image).
I'm ultimately creating my navigation in a Global with a Headline and some Links and the Headline should only appear if each block has some links;
{% for block in entry.links %}
    {% if entry.navigationLinks | length %}
        {{ block.navigationHeadline }}
        {# Show the navigationHeadline if it has links #}
        
            {% for row in entry.navigationLinks %}
                {{ row.linkLabel }} - {{ row.linkUrl }}
            {% endfor %}
        
    {% endif %}
{% endfor %}

I wondered if anyone can help me resolve my obvious errors. Thanks.

**Tags:** matrix, globals, table-field


---

## 1 answers

### Answer by username_1 on 2015-03-17. Score: 7 | Accepted answer

Not sure why you're referencing "entry" in your code, I'd think the code should be:
{% for block in footer.links %}
  {% if block.navigationLinks | length %}
    {{ block.navigationHeadline }}
    {# Show the navigationHeadline if it has links #}
    
      {% for row in block.navigationLinks %}
        {{ row.linkLabel }} - {{ row.linkUrl }}
      {% endfor %}
    
  {% endif %}
{% endfor %}

So, "links" is the matrix on your "footer" global, which you can access from anywhere. You loop over that, get a block for each matrix block, and access "navigationHeadline" and "navigationLinks" through that.


---

