<p>I found a solution:</p>
<pre><code>{% include &quot;_private/partials/matrix&quot; with {blocks: entry.bodyContent.typeId(null).all()} %}
</code></pre>
<p>This fetches all Matrixobjects from any type.
So it works now.</p>
<p>But I don't undestand, why this is necessary.
Maybe its because I used for my first project <a href="https://github.com/craftcms/starter-blog#:%7E:text=Craft%20CMS%20Blog%20Starter,with%20the%20Twig%20templating%20language." rel="nofollow noreferrer">this Blogstarter</a>.</p>
<p>Maybe there are some relicts from craft2 inside.</p>
<p>So I have the solution to my problem - but it would be nice to know why this was necessary.</p>

CC BY-SA 4.0
2020-09-23T11:23:21.167Z
2020-09-23T11:23:21.167Z
Slowwie
<p>Without seeing the code of your template <code>_private/partials/matrix</code> it's not easy to help you.</p>
<p>Maybe you need to check the block type first.
I usually do that with a switch and have a different partial for each block.</p>
<p>So your template <code>_private/partials/matrix</code> could look something like this:</p>
<pre><code>{% for block in blocks %}
  {% switch block.type %}
    {% case &quot;richText&quot; %}
      {% include &quot;_private/partials/richtext&quot; %}
    {% case &quot;quote&quot; %}
      {% include &quot;_private/partials/qoute&quot; %}
    {% case &quot;image&quot; %}
      {% include &quot;_private/partials/image&quot; %}
    {% case &quot;embed&quot; %}
      {% include &quot;_private/partials/embed&quot; %}
    {% default %}
  {% endswitch %}
{% endfor %}
</code></pre>
<p>The quote partial could look something like this</p>
<pre><code>{# do something with block.style #}
&lt;h4&gt;{{block.quote}}&lt;/h4&gt;
&lt;h5&gt;{{block.attribution}}&lt;/h5&gt;
</code></pre>

CC BY-SA 4.0
2020-09-23T11:19:05.163Z
Thank you for help. The problem is, there are just the Matrix objects with the type of 'richText' the rest ist not even fetched.
Slowwie
CC BY-SA 4.0
2020-09-23T07:22:39.777Z
2020-09-23T07:22:39.777Z
Steven Vandemoortele
<p>I have some matrix fields defined:</p>
<p><a href="https://i.sstatic.net/Lpxz3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Lpxz3.png" alt="enter image description here" /></a></p>
<p>But when I use the matrix blocks inside of an entry - I don't get all blocks - just the richText ones.</p>
<p>I tested it out - just the richtText Matrix blocks will be loaded when I do:</p>
<pre><code>  {% include &quot;_private/partials/matrix&quot; with {blocks: entry.bodyContent.all()} %}
</code></pre>
<p>Is there something I am missing, or is this a bug?</p>
<p>Would be great if someone could help.</p>

<templating><matrix><frontend><elementquery>
Matrix fields don't load!
# Matrix fields don't load!

(Asked by: username_0 on 2020-09-22)

I have some matrix fields defined:

But when I use the matrix blocks inside of an entry - I don't get all blocks - just the richText ones.
I tested it out - just the richtText Matrix blocks will be loaded when I do:
  {% include "_private/partials/matrix" with {blocks: entry.bodyContent.all()} %}

Is there something I am missing, or is this a bug?
Would be great if someone could help.

**Tags:** templating, matrix, frontend, elementquery

---

## 2 answers

### Answer by username_0 on 2020-09-23. Score: 1

I found a solution:
{% include "_private/partials/matrix" with {blocks: entry.bodyContent.typeId(null).all()} %}

This fetches all Matrixobjects from any type.
So it works now.
But I don't undestand, why this is necessary.
Maybe its because I used for my first project this Blogstarter.
Maybe there are some relicts from craft2 inside.
So I have the solution to my problem - but it would be nice to know why this was necessary.


---

### Answer by username_1 on 2020-09-23. Score: 1

Without seeing the code of your template _private/partials/matrix it's not easy to help you.
Maybe you need to check the block type first.
I usually do that with a switch and have a different partial for each block.
So your template _private/partials/matrix could look something like this:
{% for block in blocks %}
  {% switch block.type %}
    {% case "richText" %}
      {% include "_private/partials/richtext" %}
    {% case "quote" %}
      {% include "_private/partials/qoute" %}
    {% case "image" %}
      {% include "_private/partials/image" %}
    {% case "embed" %}
      {% include "_private/partials/embed" %}
    {% default %}
  {% endswitch %}
{% endfor %}

The quote partial could look something like this
{# do something with block.style #}
{{block.quote}}
{{block.attribution}}

> **Comments:**
> **username_0**: Thank you for help. The problem is, there are just the Matrix objects with the type of 'richText' the rest ist not even fetched.  

---

