I need help hiding a filter section when there are no tags to display for the current collection.
Below is the code I am currently using:
{% assign colors = 'Blue, Grey, Black, Oak, Bronze, Pewter, Gunmetal, Utile, Mahogany' | split: ',' %}
{% assign colorCount = colors | size %}
<ul class="subnav clearfix" {% if colorCount <= 0 %} style="display: none;" {% endif %}>
<li class="coll-filter filter-heading clearfix">
<label>Color</label>
<hr class="hr--sidebar">
{% for c in colors %}
{% assign tag = c | strip %}
{% if current_tags contains tag %}
<li class="selection{% unless current_tag %} active{% endunless%}">
<span>{{ tag | link_to_remove_tag: tag }}</span>
</li>
{% elsif collection.tags contains tag %}
<li class="selection{% unless current_tag %} active{% endunless%}">
<div id="swatch-{{ tag }}" class="colour-filter"> </div>
<span> {{ tag | link_to_tag: tag }}</span>
</li>
{% endif %}
{% endfor %}
</li>
</ul>
{% assign materials = 'Egyptian Cotton, Silk, Satin, Salt' | split: ',' %}
{% assign materialCount = materials | size %}
<ul class="subnav clearfix" {% if materialCount <= 0 %} style="display: none;" {% endif %}>
<li class="coll-filter filter-heading clearfix">
<label>Material</label>
<hr class="hr--sidebar">
{% for m in materials %}
{% assign tag = m | strip %}
{% if current_tags contains tag %}
<li {% unless current_tag %}class="active"{% endunless%}>
{{ tag | link_to_remove_tag: tag }}
</li>
{% elsif collection.tags contains tag %}
<li>
{{ tag | link_to_tag: tag }}
</li>
{% endif %}
{% endfor %}
</li>
</ul>
{% assign sizes = 'Small, Medium, Large' | split: ',' %}
{% assign sizeCount = sizes | size %}
<ul class="subnav clearfix" {% if sizeCount <= 0 %} style="display: none;" {% endif %}>
<li class="coll-filter filter-heading clearfix">
<label>Size</label>
<hr class="hr--sidebar">
{% for s in sizes %}
{% assign tag = s | strip %}
{% if current_tags contains tag %}
<li {% unless current_tag %}class="active"{% endunless%}>
{{ tag | link_to_remove_tag: tag }}
</li>
{% elsif collection.tags contains tag %}
<li>
{{ tag | link_to_tag: tag }}
</li>
{% endif %}
{% endfor %}
</li>
</ul>
{% assign priceRanges = 'Under £5, £15-£100, £100-£250, £250-£750, £750-1000£, £1000' | split: ',' %}
{% assign priceRangeCount = priceRanges | size %}
<ul class="subnav clearfix" {% if priceRangeCount <= 0 %} style="display: none;" {% endif %}>
<li class="coll-filter filter-heading clearfix">
<label>Price Range</label>
<hr class="hr--sidebar">
{% for p in priceRanges %}
{% assign tag = p | strip %}
{% if current_tags contains tag %}
<li {% unless current_tag %}class="active"{% endunless%}>
{{ tag | link_to_remove_tag: tag }}
</li>
{% elsif collection.tags contains tag %}
<li>
{{ tag | link_to_tag: tag }}
</li>
{% endif %}
{% endfor %}
</li>
</ul>
I have tried updating my code based on the suggestions provided, but it is still not functioning correctly.
Is it possible that having multiple filters and assigning different variables such as size, colorCount, materialCount, and priceRangeCount to the tags could be causing the issue?
Thank you for any assistance.