1

For a week-long schedule, I'm trying to group events that occur on the same day, and also fall into one of two classifications— they are free if a pass is purchased or not included in the pass.

{% set passEvents = craft.entries.section("event").eventForwardPass("No").find() %}
{% for date, entries in passEvents | group("eventStartDate|date('F d, Y')") %}

    <p>ONLY list Non-Forward Pass events.</p>

    <h2>{{date}}</h2>
    <ul>
      {% for entry in passEvents %}

          <li>{{ entry.title }}- {{entry.eventStartDate}}</li>

      {% endfor %}
    </ul>

    </section>

{% endfor %}

I'm only showing the date next to the title to verify when the code works properly. The problem I'm having is this code seems to return all entries that match the 'set' criteria under each date, rather than just the entries that match the 'set' criteria for that particular date.

I'm basing the code off of examples that would normally group by month or year. It seems like I'm asking for the right things, but obviously, the results tell me, that I'm asking for the wrong thing on the loop.

1 Answer 1

2

Figured it out. I actually asked for all entries for the group, rather than just the entries (events) that matched the date.

{% set passEvents = craft.entries.section("event").eventForwardPass("Yes").status('live','pending').order('eventStartDate').find() %}
{% for date, events in passEvents|group('eventStartDate') %}

    <h3>{{date}}</h3>

    {% for entry in events %}
        <article class="none">
            <section class=txt>
               {% if entry.eventLinkOverride == 1 %}
                  <h1><a href="{{ entry.eventLink }}">{{ entry.title }}</a></h1>
                {% else %}
                   <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1>
                {% endif %}

            </section>
        </article>
        {% endfor %}
    {% endfor %}

Your Answer

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

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