<pre><code>{% cache %}
  {% set entry = craft.entries.slug('team').last() %}
  {% for field in entry.getFieldLayout().getFields() %}
    {% if field.getField().type == "Matrix" %}
      {% set fieldHandle = field.getField().handle %}
      {% set matrixBlocks = entry.__get(fieldHandle).find() %}
      {% for block in matrixBlocks %}
        {{ block.team_name }}
      {% endfor %}
    {% endif %}
  {% endfor %}
{% endcache %}
</code></pre>

CC BY-SA 3.0
2014-11-18T15:49:02.847Z
2014-11-18T15:49:02.847Z
Mark Notton
<p>I came across a specific situation where I needed to list out all the values within a collection of Matrix fields on a single entry page. </p>

<p>More specifically, I had a single entry that needed multiple team groups, each with the name, role, and description of various people. I then wanted to list them all out anywhere on the site (single or entry pages). </p>

<p>Hope this solution helps people out. Feel free to critique.</p>

<matrix>
How to list all Matrix Blocks from anywhere, using a slug?
# How to list all Matrix Blocks from anywhere, using a slug?

(Asked by: username_0 on 2014-11-18)

I came across a specific situation where I needed to list out all the values within a collection of Matrix fields on a single entry page.

More specifically, I had a single entry that needed multiple team groups, each with the name, role, and description of various people. I then wanted to list them all out anywhere on the site (single or entry pages).

Hope this solution helps people out. Feel free to critique.

**Tags:** matrix

---

## 1 answers

### Answer by username_0 on 2014-11-18. Score: 1 | Accepted answer

{% cache %}
  {% set entry = craft.entries.slug('team').last() %}
  {% for field in entry.getFieldLayout().getFields() %}
    {% if field.getField().type == "Matrix" %}
      {% set fieldHandle = field.getField().handle %}
      {% set matrixBlocks = entry.__get(fieldHandle).find() %}
      {% for block in matrixBlocks %}
        {{ block.team_name }}
      {% endfor %}
    {% endif %}
  {% endfor %}
{% endcache %}


---

