I have a drop down that lists all the Calendars. However I would like to only show Calendars that have an event assigned to them.

I need something like the show_empty tag for EE Category Archive: http://ellislab.com/expressionengine/user-guide/add-ons/channel/category_archive.html#show-empty


You can use {exp:calendar:calendars} to list calendars, and pass the {calendar_id} to {exp:calendar:events} or {exp:calendar:cal} to see if there are any event entries for that calendar.

Given that there can be variables clashes with common variables such as {total_results}, {count}, etc, you will likely need to embed the {exp:calendar:events} or {exp:calendar:cal} code.

Here's an example. In your template use:

<select name="something">
  {embed="calendars/embed" calendar_id="{calendar_id}"}

Then, in /calendars/embed, use:

{exp:calendar:events calendar_id="{embed:calendar_id}" date_range_start="12 months ago" date_range_end="+12 months"}
    {if no_results}

    {if count == 1}
        [{calendar_id}] {calendar_title}<br />


Using a timeframe, with date_range_start="" and date_range_end="", large enough to cover your events is important, or else you only get a subset of the total events present for a calendar.

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.