<p>You should be able to do this like so:</p>

<pre><code>{% for block in entry.productIndo.type('specifications') %}
    {% for download in block.downloads %}
        {{ download.url }}
    {% endfor %}
{% endfor %}
</code></pre>

<p>Of if the nested loops don't suit you:</p>

<pre><code>{% set specificationBlock = entry.productIndo.type('specifications').first() %}

{% if specificationBlock %}
    {% for download in block.specificationBlock %}
        {{ download.url }}
    {% endfor %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-07-02T20:31:36.533Z
2014-07-02T20:31:36.533Z
Brad Bell
<p>When they exist, I'd like to get specification PDFs from a product entry. They're stored in a <code>productInfo</code> Matrix field, in a <code>specifications</code> block that has a <code>downloads</code> Assets collection.</p>
<p>Naturally I attempted the following...</p>
<pre><code>{% set specFiles = entry.productInfo.specifications.downloads %}
{% for specFile in specFiles %}
    {{ specFile.title }}
{% endfor %}
</code></pre>
<p>...and Craft thought I was being greedy:</p>
<blockquote>
<p><strong>Internal Server Error</strong></p>
<p>Craft\ElementCriteriaModel and its behaviors do not have a method or closure named &quot;specifications&quot;.</p>
</blockquote>
<p>I noticed in <a href="https://craftcms.stackexchange.com/questions/39/search-matrix-for-blocks-with-upcoming-dates">this SE question</a> that examples skipped referencing the block type and went straight for the field name, so I tried that next...</p>
<pre><code>{% set specificationDownloads = entry.productInfo.downloads %}
{% for specFile in specificationDownloads %}
    {{ specFile.title }}
{% endfor %}
</code></pre>
<p>This didn't throw any error, but it didn't return any results either.</p>
<p>I know that I can loop through the blocks and then the downloads, it just seems excessive...</p>
<pre><code>{% for block in entry.productInfo %}
    {% if block.type == 'specifications' %}
        {% for specFile in block.downloads %}
            {{ specFile.title }}
        {% endfor %}
    {% endif %}
{% endfor %}
</code></pre>
<p>So what <em>is</em> the most straightforward way to get results when I want to limit them to a specific (Assets) field within a certain Matrix block type?</p>

<templating><matrix>
Can I get Assets from a specific Matrix block?
# Can I get Assets from a specific Matrix block?

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

When they exist, I'd like to get specification PDFs from a product entry. They're stored in a productInfo Matrix field, in a specifications block that has a downloads Assets collection.
Naturally I attempted the following...
{% set specFiles = entry.productInfo.specifications.downloads %}
{% for specFile in specFiles %}
    {{ specFile.title }}
{% endfor %}

...and Craft thought I was being greedy:

Internal Server Error
Craft\ElementCriteriaModel and its behaviors do not have a method or closure named "specifications".

I noticed in this SE question that examples skipped referencing the block type and went straight for the field name, so I tried that next...
{% set specificationDownloads = entry.productInfo.downloads %}
{% for specFile in specificationDownloads %}
    {{ specFile.title }}
{% endfor %}

This didn't throw any error, but it didn't return any results either.
I know that I can loop through the blocks and then the downloads, it just seems excessive...
{% for block in entry.productInfo %}
    {% if block.type == 'specifications' %}
        {% for specFile in block.downloads %}
            {{ specFile.title }}
        {% endfor %}
    {% endif %}
{% endfor %}

So what is the most straightforward way to get results when I want to limit them to a specific (Assets) field within a certain Matrix block type?

**Tags:** templating, matrix

---

## 1 answers

### Answer by username_1 on 2014-07-02. Score: 8 | Accepted answer

You should be able to do this like so:
{% for block in entry.productIndo.type('specifications') %}
    {% for download in block.downloads %}
        {{ download.url }}
    {% endfor %}
{% endfor %}

Of if the nested loops don't suit you:
{% set specificationBlock = entry.productIndo.type('specifications').first() %}

{% if specificationBlock %}
    {% for download in block.specificationBlock %}
        {{ download.url }}
    {% endfor %}
{% endif %}


---

