I'm outputting occurrences using the {occurrences} variable pair within a {exp:calendar:events} tag for a single day and I'd like to sort these occurrences by time.

{exp:calendar:events calendar_id="22" date_range_start="2013-11-10" date_range_end="2013-11-10" sort="asc" show_years="9" pad_short_weeks="n"}

      {occurrence_start_date format="%D, %F %j %g:%i %a"}


I tried using the sort parameter in the occurrences variable pair and but it didn't work. Any tips?

2 Answers 2


I actually just ran into a similar issue with Solspace Calendar. The add-on is written so that ordering in this way is not possible (it has a built-in ordering process). You can't even use the fixed_order= parameter.

In the end, I had to utilize Stash to first grab all the event occurrences and set them into a list, then grab that Stash list and sort using Stash.

So, after you install Stash, try this:

{exp:stash:set_list name="event_occurrences" parse_tags="yes"}
  {exp:calendar:events calendar_id="22" date_range_start="2013-11-10" date_range_end="2013-11-10" show_years="9" pad_short_weeks="n"}
      {stash:occurrence_start_date_hour}{occurrence_start_date format="%D, %F %j %g:%i %a"}{/stash:occurrence_start_date_hour}
      {stash:occurrence_time_sort}{occurrence_start_date format="%Y%m%d%H%i"}{/stash:occurrence_time_sort}

Then use Stash to display them in order by sorting according to {stash:occurrence_time_sort}

{exp:stash:get_list name="event_occurrences" orderby="occurrence_time_sort" sort="desc"}
  • Looks like a very convoluted way of getting a chronological list of events, when a simple {exp:calendar:cal} tag would do the same job. My two cents. :)
    – Solspace
    Oct 24, 2013 at 17:01
  • @Solspace, true. :) I had to use this for custom ordering of events (not occurrences). Forgot about the :cal tag. Oct 24, 2013 at 17:34
  • @Solspace: I think that this is the only way to get events list with one occurrence where the events are grouped and not showed "double/triple" as when using cal tag. as I can see, there is no way for limit-per-event listing in Cal tag.
    – Davor Peic
    May 29, 2014 at 13:23
  • @DavorPeic You could do it with {exp:calendar:cal} and some PHP, building an array to prune out "duplicates". Likely a Stash approach is also possible. The other advantage is that everything stays chronological, too.
    – Solspace
    May 30, 2014 at 20:56

If you're looking to order occurrences chronologically, you should be using {exp:calendar:cal}. This is the only tag that will order occurrences in true chronological order. Details on why/how can be found here: http://www.solspace.com/docs/calendar/getting_started/

  • So would the proper form to output occurrences for a day and to have those occurrences ordered by start date: {exp:calendar:cal calendar_id="22" date_range_start="2013-11-10" date_range_end="2013-11-10" sort="asc" show_years="9" pad_short_weeks="n"} {events} {occurrences orderby="occurrence_start_date" sort="asc"} {occurrence_start_date format="%D, %F %j %g:%i %a"} {/occurrences} {/events} {/exp:calendar:cal} Oct 25, 2013 at 13:40
  • Close. You don't need show_years="" if the timeframe is a specific day. Same for sort="": {exp:calendar:cal} is already chronological. Also, {occurrences}{/occurrences} (which doesn't accept parameters, btw) is not needed. It would be rather this: {exp:calendar:cal calendar_id="22" date_range_start="2013-11-10" date_range_end="2013-11-10" pad_short_weeks="n"} {events} {event_start_date format="%D, %F %j %g:%i %a"} {/events} {/exp:calendar:cal}
    – Solspace
    Oct 26, 2013 at 1:30

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.