1

I'm a bit confused by the way that Craft now handles Matrix blocks. I've read the documentation a few times and I'm still not sure if I have it.

Here's what I have:

{% set myMatrixBlockQuery = craft.matrixBlocks().ownerId(4).type('block__artists') %}
{% set matrixBlocks = myMatrixBlockQuery.all() %}
{% for block in matrixBlocks %}
  <li>{{ block.id }} / {{ block.artistName }}</li>
{% endfor %}

But all that gets output is:

8 /
9 /
10 /

Where 10 (etc) is the ID of the block. It's not outputting the artistName despite that field existing and having content. Is my query wrong?

2
  • is your artistName field a plaintext field? What outputs when you do {{ dump(block) }} inside your loop? Commented Jan 17, 2019 at 16:45
  • Yeah it's a plaintext field. The output I get mostly all seem to be attributed as NULL which is weird. One of the only fields that isn't is the ID field. Full output is here: pastebin.com/EFQp64Ya — this is looped over 3 times
    – Chrish
    Commented Jan 17, 2019 at 17:11

1 Answer 1

2

I think you need to add the fieldId() param to your query as per https://github.com/craftcms/cms/issues/1789

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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