Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 7 down vote accepted

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 %}
share|improve this answer
.type()! Thank you, Brad. – Matt Stein Jul 2 '14 at 20:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.