Closed pixeldeluxe closed 7 years ago
The field definitely isn’t optimized for this use case, but you could loop through each of the days and check their values:
{% set hasHours = false %}
{% for day in entry.storeHours %}
{% if not hasHours and (day.open or day.close) %}
{% set hasHours = true %}
{% endif %}
{% endfor %}
Bonus points if you use the {% break %}
tag provided by the MN Twig Perversion plugin:
{% set hasHours = false %}
{% for day in entry.storeHours %}
{% if day.open or day.close %}
{% set hasHours = true %}
{% break %}
{% endif %}
{% endfor %}
How do I Check is none of the storeHours is filled? When you save the storeHours|length will be 7 instead of 0.
{% if entry.storeHours|length %} ... {% endif %}