I have a channel with categories and an entries field. I need to first group all entries by their category. This is working fine.
{% set entries = craft.entries.section('publicationsChannel') %}
{% set relatedCats = craft.categories.relatedTo(entries) %}
{% for category in relatedCats %}
{{ category.title }}
{% for entry in relatedEntries %}
{# this list of entries needs to be grouped by the regionCountry field #}
{{ entry.title }} <br>
{% endfor %}
{% endfor %}
However what I now need to do is take the list of entries and further organize them according to a relationship field handle regionCountry
There are only 3 entries in that channel Canada, US, UK and they need to be grouped in that order.
I can't seem to wrap my head around the logic needed to do this.
What I need finally is.
Category 1
- Canada
- entry 1
- entry 2
- US
- entry 1
- entry 2
- UK
- entry 1
- entry 2
Category 2
- Canada
- entry 1
- entry 2
- US
- entry 1
- entry 2
- UK
- entry 1
- entry 2 etc...