I'm wondering if I might have a little too much inception madness in my thinking with this problem.

Enhancing a site we built for a conference last year. As there's an annual conference each year and some of the speakers are the same, we decided to reevaluate the approach.

What we have now is 2 channels, Speaker and Conference. Speaker contains all the speakers that could ever make an appearance at the conference and Conference contains the specific details about that conference.

Within conference, we have a Matrix field called Talks with a workshop, general and special event block.

I want to be able to group talk blocks by their block type, is that possible?

Going a step further, in the case of a workshop - that block has a workshopRound select field of 1, 2 or 3 - I'd love to be able to then group entries with those blocks by their round number.

Any thoughts on how this could be achieved?

1 Answer 1


This is a great chance to use the group filter.

First, get all your matrix blocks as an array:

{% set talkBlocks = entry.talks.find() %}

Then group them by type:

{% set talksByCategories = talkBlocks|group('type') %}

At this point, you have an associative array where the keys are the block types, and the values are arrays of the blocks with that type. So talksByCategories.workshop or talksByCategories['workshop'] will be the workshops.

You can group the workshops by round:

{% set workshopsByRound = talksByCategories.workshop|group('workshopRound.value') %}

You should check that there were any workshops first (twig's defined test):

{% if talksByCategories['workshop'] is defined %} ...

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.