<p>How about:</p>

<pre><code>{% for block in entry.myMatrix if block.subsection == 'intro' %}
    ...
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-07-12T16:55:49.917Z
This displays an error for me: "Internal Server Error

Craft\MatrixBlockModel and its behaviors do not have a method or closure named "subsection"."
cmal
CC BY-SA 3.0
2014-07-12T17:19:43.080Z
Can you post a screenshot of your Matrix field? I just want to make sure I'm visualizing it correctly.
Tyler Willingham
CC BY-SA 3.0
2014-07-12T17:45:39.013Z
Tyler: Here is a [screenshot](http://cl.ly/image/1H0x1H3J0L1k). I made some of the names more generic than my actual case (obviously I don't call my Matrixes "myMatrix"!) but the scenario is still the same. More realistic code based on this screenshot would be `{% for block in entry.approachBlurb if block.subsection('team') %}`
cmal
CC BY-SA 3.0
2014-07-12T18:09:07.613Z
I replicated your setup and tested against block.subsection == 'research'. I updated my answer with a functioning conditional :) Let me know if this still doesn't work for you.
Tyler Willingham
CC BY-SA 3.0
2014-07-12T03:41:26.330Z
2014-07-12T18:08:21.950Z
2014-07-12T18:08:21.950Z
Tyler Willingham
<p>I'm in the context of an Entry that has a Matrix field, and one of those Matrix fields is a Dropdown called <code>subsection</code>. I want to grab all Matrix blocks that have <code>subsection</code> set to 'intro'.</p>

<p>This is how I'm trying to do it and it definitely doesn't work. Is there another way to accomplish this?</p>

<pre><code>{% for block in entry.myMatrix.subsection('intro') %}
…
{% endfor %}
</code></pre>

<templating><matrix>
Return all Matrix blocks with a drop down set to a specified value
# Return all Matrix blocks with a drop down set to a specified value

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

I'm in the context of an Entry that has a Matrix field, and one of those Matrix fields is a Dropdown called subsection. I want to grab all Matrix blocks that have subsection set to 'intro'.
This is how I'm trying to do it and it definitely doesn't work. Is there another way to accomplish this?
{% for block in entry.myMatrix.subsection('intro') %}
…
{% endfor %}

**Tags:** templating, matrix


---

## 1 answers

### Answer by username_1 on 2014-07-12. Score: 3 | Accepted answer

How about:
{% for block in entry.myMatrix if block.subsection == 'intro' %}
    ...
{% endfor %}

> **Comments:**
> **username_0**: This displays an error for me: "Internal Server Error  Craft\MatrixBlockModel and its behaviors do not have a method or closure named "subsection"."  
> **username_1**: Can you post a screenshot of your Matrix field? I just want to make sure I'm visualizing it correctly.  
> **username_0**: Tyler: Here is a [screenshot](http://cl.ly/image/1H0x1H3J0L1k). I made some of the names more generic than my actual case (obviously I don't call my Matrixes "myMatrix"!) but the scenario is still the same. More realistic code based on this screenshot would be `{% for block in entry.approachBlurb if block.subsection('team') %}`  
> **username_1**: I replicated your setup and tested against block.subsection == 'research'. I updated my answer with a functioning conditional :) Let me know if this still doesn't work for you.  

---

