2

I found a way to do something like this

 {% set allBlocks =  craft.entries.matrixes %}

Which seems to return all the matrix blocks.. or at least I think it is?

But if try to filter down like:

  {% set allBlocks =  craft.entries.matrixes.type('document') %}

I get nothing.

Any ideas how to get all the Matrix blocks by type or better still all the Matrix blocks in a particular field?

Would i need to setup a plugin for this?

5

There is no craft.entries.matrixes variable available natively in Craft.

(craft.entries returns an ElementCriteriaModel, which does not have a matrixes property explicitly set.)

So, craft.entries.matrixes is actually looking for ElementCriteriaModel->matrixes(), which could implicitly exist if:

  • You have a field called matrixes, or
  • There's a plugin in the mix that is changing functionality

You'll need a plugin to run these custom queries. Luckily Craft's MatrixService has plenty of methods that would be helpful.

Also, Low created a plugin (LowBlocks) to do this sort of thing, which might fit your need, or at least offer a helpful starting point.

1
  • Low's plugin was exactly what i needed and still works great. Thanks Michael! – Keith Mancuso Jan 10 '16 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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