<p>You will need to use your Matrix field handle (which you didn't show in your question) and replace <code>yourMatrixFieldHandle</code>:</p>

<pre><code>{% for client in clients %}
    {{ client.title }}

    {# Get all blocks related to the client entry #}
    {% for block in client.yourMatrixFieldHandle.all() %}

        {% switch block.type %}

            {% case "clientImage" %}

                {% for image in block.clientImage.all() %}
                    &lt;img src="{{ image.getUrl() }}" alt="{{ image.title }}"&gt;
                {% endfor %}

            {% case "clientDescription" %}

                {{ block.clientDescription }}

        {% endswitch %}

    {% endfor %}

{% endfor %}
</code></pre>

<p>Read more about <a href="https://docs.craftcms.com/v3/matrix-fields.html#working-with-matrix-field-data" rel="nofollow noreferrer">working with Matrix fields here</a></p>

CC BY-SA 4.0
2020-05-04T14:50:33.020Z
it works! thank you very much
Cosmin Ciolacu
CC BY-SA 4.0
2020-05-04T14:09:46.037Z
2020-05-04T14:09:46.037Z
Oli
<p>I create a section clientSection which I linked an matrix field like in this image:
<a href="https://i.sstatic.net/uCDxI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uCDxI.png" alt="screenshot"></a>
The field has two block types : <code>clientImage</code> which has an field <code>clientImage</code> and <code>clientDescription</code> which has an field with same name.
I want to output in twig file but I don't know how exactly</p>

<pre><code>{% set clients = craft.entries.section('clientSection').all() %}

{% for client in clients %}
  {# display content here #}
{% endfor %}
</code></pre>

<p>Thank's</p>

<entries><matrix>
retrieve matrix data to twig file
# retrieve matrix data to twig file

(Asked by: username_0 on 2020-05-04)

I create a section clientSection which I linked an matrix field like in this image:

The field has two block types : clientImage which has an field clientImage and clientDescription which has an field with same name.
I want to output in twig file but I don't know how exactly
{% set clients = craft.entries.section('clientSection').all() %}

{% for client in clients %}
  {# display content here #}
{% endfor %}

Thank's

**Tags:** entries, matrix


---

## 1 answers

### Answer by username_1 on 2020-05-04. Score: 1 | Accepted answer

You will need to use your Matrix field handle (which you didn't show in your question) and replace yourMatrixFieldHandle:
{% for client in clients %}
    {{ client.title }}

    {# Get all blocks related to the client entry #}
    {% for block in client.yourMatrixFieldHandle.all() %}

        {% switch block.type %}

            {% case "clientImage" %}

                {% for image in block.clientImage.all() %}
                    
                {% endfor %}

            {% case "clientDescription" %}

                {{ block.clientDescription }}

        {% endswitch %}

    {% endfor %}

{% endfor %}

Read more about working with Matrix fields here

> **Comments:**
> **username_0**: it works! thank you very much  

---

