I have a channel section called Members. I have 2 category groups (categoriesMembres & cantons).
My goal: show entries only related to a specific category in categoriesMembres and loop through the cantons:
Canton1
- entry 1
- entry 2
- etc.
Canton2
- entry 3
- entry 4
- etc.
Right now the code below display it like that:
Canton1
- entry 1
- entry 2
- entry 3
- entry 4
Canton2
- entry 1
- entry 2
- entry 3
- entry 4
The code (I stripped out html for clarity)
{% set membersCat = craft.categories.group('categoriesMembres').title('Membre').first() %}
{% set entries = craft.entries.section('listeMembres').relatedTo(membersCat) %}
{% set cantonsCat = craft.categories.group('cantons').relatedTo(entries) %}
{% for canton in cantonsCat %}
{{ canton.title }}
{% for row in entries|batch(3) %}
{% for entry in row %}
{{ entry.title }}
{% endfor %}
{% endfor %}
{% endfor %}
What am I overseeing or doing wrong?