1

I've using a matrix field from the same entry in two different templates. In one template I want them in the order they're displaying in the CMS, while in the other I want them displayed in reverse.

It doesn't like this:

{% for cta in entry.ctas.order('desc') %}

Can this be done any other way?

1 Answer 1

3

I went and looked at the MatrixBlockModel; there's an attribute named sortOrder (If you output {{sortOrder}} inside the for loop, it will display the index of that block).

You can use that attribute to sort by, in reverse:

{% for cta in entry.ctas.order('sortOrder desc') %}
0

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.