I want my <ul>
to show a single tag representing all "active" entries ( "active" using a custom lightswitch field in the entry: fellowStatus
.
Each tag is a year (e.g. 2014, 2010, etc)
E.g. if there are no "active" entries with the tag 2017
, it should not display.
The code block below spits out only tags where entries are "active"
BUT...
It spits out duplicates of each tag depending on how many entries are using it. (e.g. It displays 8 instances of 2015
instead of 1)
<ul>
{% for entry in craft.entries.section('fellows').limit(null) %}
{% set tags = craft.tags.relatedTo(entry).limit(1).find() %}
{% set active = entry.fellowStatus %}
{% if entry.fellowStatus == 0 %}
{% for tag in tags %}
<li>
<a href="{{ tag }}">{{ tag.title }}</a>
</li>
{% endfor %}
{% endif %}
{% endfor %}
</ul>
2015
has an entry, show. If2001
doesn't have an entry, don't show. If2017
has an entry, butfellowStatus
light switch is off, don't show.