<p>In the code below I am trying to check for the presence of a quote block to help define some layout columns.</p>

<p>As soon as i count an individual block, the loop block below it outputs nothing. If remove the column logic based on length of quote block the loop below then outputs.</p>

<pre><code>{# position columns width if there is a quote #}
{% if entry.contentBlock.type('quote').limit(1) | length %}
    {% set col1 = "12u$(medium) 7u  " %}
    {% set col2 = "5u 12u$(medium)  " %}
{% else %}
    {% set col1 = "12u$(small) 6u -3u  " %}
    {% set col2 = "hide " %}
{% endif %}

&lt;div class="{{ col1 }}"&gt;
    &lt;h3&gt; {{ entry.title }} &lt;/h3&gt;

    {% for block in entry.contentBlock.all() %}
        {% if block.type.handle == "text" or block.type.handle == "image" %}
            {% include ('page/_partials/_' ~ blockPrefix ~ 'block_' ~ block.type.handle) %}
        {% endif %}
    {% endfor %}
&lt;/div&gt;

&lt;div class="{{ col2 }}"&gt;
    {% for block in entry.contentBlock.type('quote').all() %}
        {% include ('page/_partials/_' ~ blockPrefix ~ 'block_' ~ block.type.handle) %}
    {% endfor %}
&lt;/div&gt;
</code></pre>

CC BY-SA 4.0
2018-11-27T04:43:27.217Z
I'm assuming this is for Craft 3?
Brad Bell
CC BY-SA 4.0
2019-01-21T14:28:05.307Z
Yes this is for craft 3
joomkit
<matrix>
Why does calling matrix block type before matrix block loop lead to no loop output
# Why does calling matrix block type before matrix block loop lead to no loop output

(Asked by: username_0 on 2018-11-25)

In the code below I am trying to check for the presence of a quote block to help define some layout columns.
As soon as i count an individual block, the loop block below it outputs nothing. If remove the column logic based on length of quote block the loop below then outputs.
{# position columns width if there is a quote #}
{% if entry.contentBlock.type('quote').limit(1) | length %}
    {% set col1 = "12u$(medium) 7u  " %}
    {% set col2 = "5u 12u$(medium)  " %}
{% else %}
    {% set col1 = "12u$(small) 6u -3u  " %}
    {% set col2 = "hide " %}
{% endif %}


     {{ entry.title }} 

    {% for block in entry.contentBlock.all() %}
        {% if block.type.handle == "text" or block.type.handle == "image" %}
            {% include ('page/_partials/_' ~ blockPrefix ~ 'block_' ~ block.type.handle) %}
        {% endif %}
    {% endfor %}



    {% for block in entry.contentBlock.type('quote').all() %}
        {% include ('page/_partials/_' ~ blockPrefix ~ 'block_' ~ block.type.handle) %}
    {% endfor %}

**Tags:** matrix

> **Comments:**
> **username_1**: I'm assuming this is for Craft 3?  
> **username_0**: Yes this is for craft 3  

---

## 0 answers

