<p>You would loop through the Matrix field within each <code>tab</code> the same way you’d do it for any other element.</p>

<pre class="lang-twig prettyprint-override"><code>{% set tabs = entry.descendants %}
{% for tab in tabs %}
    {{ tab.title }}
    {% for block in tab.myMatrixFieldHandle %}
        {% if block.type == 'about' %}
            ...
        {% elseif block.type == 'team' %}
            ...
        {% elseif block.type == 'clients' %}
            ...
        {% endif %}
    {% endfor %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-10-26T04:03:56.617Z
Thanks - my problem was in naming as my matrixFieldHandle was actually called 'tab' - bit of a Herp Derp moment!
Ryan
CC BY-SA 3.0
2014-10-20T23:55:40.823Z
2014-10-20T23:55:40.823Z
Brandon Kelly
<p>I have a structure with 1 main Entry and 3 descendants underneath it but I have trouble accessing the data in matrix fields in the entries. I'm trying to do this all on one page:</p>

<pre><code>{% set tabs = entry.descendants %}
     {% for tab in tabs %}
          {{ tab.title }}
     {% endfor %}
{% endfor %}
</code></pre>

<p>I can get as far as the tab title, and it displays fine. But I want to access the matrix fields in the descendants. Here are the blocks in my field with the handle 'tab'. </p>

<p><img src="https://i.sstatic.net/dzkAU.png" alt="Blocks"></p>

<p>So to summarise, I have a structure:</p>

<p><img src="https://i.sstatic.net/03WvP.png" alt="Structure"></p>

<p>and then I want to use all those descendant data all one one page but I'm having trouble accessing it.</p>

<matrix><structure><entrymodel>
Accessing structure descendants data
# Accessing structure descendants data

(Asked by: username_0 on 2014-10-19)

I have a structure with 1 main Entry and 3 descendants underneath it but I have trouble accessing the data in matrix fields in the entries. I'm trying to do this all on one page:
{% set tabs = entry.descendants %}
     {% for tab in tabs %}
          {{ tab.title }}
     {% endfor %}
{% endfor %}

I can get as far as the tab title, and it displays fine. But I want to access the matrix fields in the descendants. Here are the blocks in my field with the handle 'tab'. 

So to summarise, I have a structure:

and then I want to use all those descendant data all one one page but I'm having trouble accessing it.

**Tags:** matrix, structure, entrymodel

---

## 1 answers

### Answer by username_1 on 2014-10-20. Score: 2 | Accepted answer

You would loop through the Matrix field within each tab the same way you’d do it for any other element.
{% set tabs = entry.descendants %}
{% for tab in tabs %}
    {{ tab.title }}
    {% for block in tab.myMatrixFieldHandle %}
        {% if block.type == 'about' %}
            ...
        {% elseif block.type == 'team' %}
            ...
        {% elseif block.type == 'clients' %}
            ...
        {% endif %}
    {% endfor %}
{% endfor %}

> **Comments:**
> **username_0**: Thanks - my problem was in naming as my matrixFieldHandle was actually called 'tab' - bit of a Herp Derp moment!  

---

