Answers.Body: <p>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 <code>currentDay|lower</code> many, many times. </p>
  
  <p>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 <code>{% set currentDayLower = currentDay|lower %}</code> once around line 4 and then compare <code>{% if day == currentDayLower %}</code> in order to avoid re-doing a filter in a loop.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-12T01:53:03.947Z
Answers.LastActivityDate: 2016-05-12T01:53:03.947Z
Answers.UserDisplayName: maxfenton
Body: <p>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:</p>
  
  <pre><code>{% 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 %}
          &lt;li&gt;{{ entry.title }}&lt;/li&gt;
        {% endif %}
      {% endfor %}
    {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>As you can see I'm looping over all the <code>entries</code> in the craft category 'shows', then looping over the SuperTable row <code>showschedule</code>, then looping over the checkbox category <code>airingdatesEn</code> to see if it contains the current day.</p>
  
  <p>Seems like I'm doing a lot of barrel rolls here, any ideas on how to simplify?</p>
  
  <p>Thanks!</p>
  
Tags: <plugin-supertable>
Title: Simplify templating query with Super Table
ThreadText: # Simplify templating query with Super Table
  
  (Asked by: username_0 on 2016-05-11)
  
  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?
  
  Thanks!
  
  **Tags:** plugin-supertable
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-12. Score: 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.
  
  
  ---
  
  