I have a channel of Musical Compositions:
Now all these Compositions have a Composer. All the composers are stored in a separate channel and then linked with their respective compositions trough a entries field
Now I like to order the compositions by the last name of the composer and group them together alphabetically.
I managed them to be grouped but not by the composer name, just by the composition title which is not helpful.
{% set allEntries = craft.entries.section('komposition').limit(null) %}
{% set allEntriesByPrename = allEntries | group('title|upper|slice(0, 1)') %}
{% for letter, allEntriesSorted in allEntriesByPrename %}
{# stuff #}
{% endfor %}
Now the catch here is the group filter I guess but when I use the handle of the entries field it doesn't work:
| group('composerRelated.lastName|upper|slice(0, 1)')
If I write it like this, the group filter simply is ignored. Since the entries field returns an array I have no idea how to write this. And I think at the time of the group filter the entries field is not available yet.
I also tried to grab all composers from the section and put it into the group filter:
{% set allEntries = craft.entries.section('komposition').limit(null) %}
{% set composerName = craft.entries.section('komponist').limit(null) %}
{% set allEntriesByPrename = allEntries | group('composerName.lastName|upper|slice(0, 1)') %}
This is too much inception for me. How do I have to write this?