The following code will return the correct result, but since I'm quite new with Craft, I wanted to know if there was a more preferred/efficient way to filter this in the template (or maybe create a custom function). Here we go:

{% set currentDay = now|date('l') %}
{% set currentTime = now|date('H:i') %}
{% set entries = craft.categories.group('shows') %}

{% for entry in entries %}
  {% for row in entry.showschedule %}
    {% for day in row.airingDatesEn %}
      {% if day == currentDay|lower %}
        <li>{{ entry.title }}</li>
      {% endif %}
    {% endfor %}
  {% endfor %}
{% endfor %}

As you can see I'm looping over all the entries in the craft category 'shows', then looping over the SuperTable row showschedule, then looping over the checkbox category airingdatesEn to see if it contains the current day.

Seems like I'm doing a lot of barrel rolls here, any ideas on how to simplify?


1 Answer 1


Someone else will surely better answer the larger question you're asking, but one small point: as you've written it, you're running the filter currentDay|lower many, many times.

Since that will be static for the duration of the loop, even if Craft/twig doesn't have more efficient ways to handle your query, you should do something like {% set currentDayLower = currentDay|lower %} once around line 4 and then compare {% if day == currentDayLower %} in order to avoid re-doing a filter in a loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.