0

I'm using Solspace calendar and I'm wondering is it possible to filter the events by weekdays? For example, I'd like to show events that only occur on Monday to Friday, I can't really see any way of doing it in the documentation.

1

You can do this using conditionals.

If you're looping through each day, you can filter by a day, eg. Sunday, this way:

{exp:calendar:cal date_range_start="today" date_range_end="+6 months" pad_short_weeks="n"}
  {display_each_day}
    {if '{day format="%D"}' == 'Sun'}
      <p>{day format="%Y.%m.%d"} is on a Sunday. Here are the events on this day:</p>
      <ul>
      {events}
        <li>{event_title}</li>
      {/events}
      </ul>
    {/if}
  {/display_each_day}
{/exp:calendar:cal}

Alternatively, if you're looping through events, you could use {event_start_date} to build a similar filtering conditional:

{exp:calendar:cal date_range_start="today" date_range_end="+6 months" pad_short_weeks="n"}
  {events}
    {if '{event_start_date format="%D"}' == 'Sun'}
      <p>The following event is on a Sunday:</p>
      <ul>
        <li>{event_title}, starts on {event_start_date format="%Y.%m.%d"}</li>
      </ul>
    {/if}
  {/events}
{/exp:calendar:cal} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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