ExpressionEngine Add-ons

Calendar:Day template tag

The Calendar:Day tag handles "day-based" formatting and displays an event list for a specified date, or today's date.

click to enlarge

{exp:calendar:day} content {/exp:calendar:day}

Parameters

The following parameters are available for use:

author_id=

author_id="1"

This parameter allows you to filter down the event results by the author of the Calendar event entries. You can hardcode a member ID, pass it through an embed, or grab it from the URI. You can also use CURRENT_USER to display event entries for the currently logged in user. Separate multiples with the pipe character.

calendar_id=

calendar_id="1|3"

This parameter allows you to display specific calendars by specifying their ID(s). You can hardcode a calendar ID, pass it through an embed, or grab it from the URI. Separate multiples with the pipe character.

calendar_short_name=

calendar_short_name="soccer|baseball|dodgeball"

This parameter allows you to display specific calendars by specifying their short names. You can hardcode a short name, pass it through an embed, or grab it from the URI. Separate multiples with the pipe character.

category=

category="22"

This parameter allows you to filter down the event results by the category ID assigned to calendar event entries. You can hardcode a category ID, pass it through an embed, or grab it from the URI. Separate multiples with the pipe character.

channel=

channel="baseball"

This parameter allows you to filter down the event results by the channel of the calendar event entries. You can hardcode a channel short name, pass it through an embed, or grab it from the URI. Separate multiples with the pipe character.

date_range_start=

{if segment_3}
    date_range_start="{segment_3}-{segment_4}-{segment_5}
{if:else}
    date_range_start="today"
{/if}

This parameter allows you to specify a particular day to display events for. If this parameter is NOT specified or an incorrect date value is passed to this parameter, the current day (today) will be displayed. Both standard and easy-to-use text date formatting apply to this parameter.

site=

site="siteA|siteB|siteC"

If using EE Multiple Site Manager (MSM), you can specify a site short name(s) in this parameter to filter event entries down to that site.

status=

status="open|extra"

This parameter allows you to filter down the event results by the status of the calendar event entries. You can hardcode a channel short name, pass it through an embed, or grab it from the URI. Separate multiples with the pipe character.

Variables

Most of the variables listed in Calendar:Events are available for use here (inside of the calendar:events variable pair). Additionally, the following variables are available for use as well:

calendar:next_day

{calendar:next_day format="%F %j, %Y"}

This variable displays the day after the currently viewed day. Typically used for linking to the next day. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:previous_day

{calendar:previous_day format="%F %j, %Y"}

This variable displays the day prior to the currently viewed day. Typically used for linking to previous day. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:day_date

{calendar:day_date format="%F %j, %Y"}

This variable displays the date of the currently specified day. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:day_total_events

{calendar:day_total_events}

This variable displays the total number of events that are happening for a given day. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:hour_date

{calendar:hour_date format="%g %a"}

This variable displays the date of the currently specified hour. Can only be used INSIDE of the calendar:hours variable pair, and OUTSIDE of the calendar:events variable pair.

calendar:hour_total_events

{calendar:hour_total_events}

This variable displays the total number of events that are happening for a given hour. Can only be used INSIDE of the calendar:hours variable pair, and OUTSIDE of the calendar:events variable pair.

calendar:all_day_total_events

{calendar:all_day_total_events}

This variable displays the total number of 'all day' events (all day or multi-day events). Can only be used INSIDE of the calendar:all_day_events variable pair, and OUTSIDE of the calendar:events variable pair.

Variable Pairs

The following variable pairs are available for use:

calendar:hours

{calendar:hours}{/calendar:hours}

This variable pair handles the formatting for each hour of the day. It is available to use in the event you want to break down the list of results by sections of hours. It will exclude all day and some multi-day (ones that started previous day) events. To display these, use the calendar:all_day_events variable pair.

calendar:all_day_events

{calendar:all_day_events}{/calendar:all_day_events}

This variable pair handles the formatting for events that are all day or multi-day (ones that started previous day). It will only display its contents if there are any events of this type for the given day.

calendar:events

{calendar:events}{/calendar:events}

This variable pair handles the formatting of each event result. Most of the variables listed in Calendar:Events are available for use here, prefixed with calendar:.

Conditionals

The following conditionals are available for use:

calendar:no_results

{if calendar:no_results}
    Sorry, no events are available within this specified date range.
{/if}

This conditional displays its contents when there is no event results for the given parameters. Can only be used INSIDE of the calendar:events variable pair.

calendar:event_all_day

{if calendar:event_all_day}{/if}

This conditional will displays its contents if the event is an all day event. Can only be used INSIDE of the calendar:events variable pair.

calendar:event_multi_day

{if calendar:event_multi_day}{/if}

This conditional will displays its contents the event occurs on multiple days. Can only be used INSIDE of the calendar:events variable pair.

calendar:event_recurs

{if calendar:event_recurs}{/if}

This conditional will displays its contents if the event has recurrence rules. Can only be used INSIDE of the calendar:events variable pair.

calendar:day_is_weekend

{if calendar:day_is_weekend}{/if}

This conditional is typically used for adjusting styles or formatting, and will display its contents if the day occurs on the weekend (Saturday or Sunday). Can only be used OUTSIDE of the calendar:events variable pair.

calendar:day_is_weekday

{if calendar:day_is_weekday}{/if}

This conditional is typically used for adjusting styles or formatting, and will display its contents if the day occurs on a weekday (Monday to Friday). Can only be used OUTSIDE of the calendar:events variable pair.

calendar:current_day

{if calendar:current_day}{/if}

This conditional will displays its contents if the day is in the current day / today. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:current_week

{if calendar:current_week}{/if}

This conditional will displays its contents if the day is in the current week. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:current_month

{if calendar:current_month}{/if}

This conditional will displays its contents if the day is in the current month. Can only be used OUTSIDE of the calendar:events variable pair.

calendar:current_year

{if calendar:current_year}{/if}

This conditional will displays its contents if the day is in the current year. Can only be used OUTSIDE of the calendar:events variable pair.

Examples

We strongly recommend you install the Demo Templates included with Calendar to see a more real-world, ready-to-go example that should work instantly with your site event data.

Below is a basic code example showing how this tag works:

{exp:calendar:day
    {if segment_3} {!-- Are we looking at a date other than today? --}
        date_range_start="{segment_3}-{segment_4}-{segment_5}"
    {if:else} {!-- Or are we looking at today's date? --}
        date_range_start="today"
    {/if}
}
    <p>
        <a href="{path='calendar/day'}/{calendar:previous_day format="%Y/%m/%d"}/">Previous Day</a>
        <b>{calendar:day_date format="%l, %F %j, %Y"}</b> ({calendar:day_total_events} events)
        <a href="{path='calendar/day'}/{calendar:next_day format="%Y/%m/%d"}/">Next Day</a>
    </p>
    {calendar:all_day_events}
        <ul>
        {calendar:events}
            <li><a href="{path='calendar/events'}/{calendar:url_title}/">{calendar:title}</a> (all day)</li>
        {/calendar:events}
        </ul>
    {/calendar:all_day_events}
    {calendar:hours}
        <h4>{calendar:hour_date format="%g %a"}</h4>
        {calendar:events}
            <h3><a href="{path='calendar/events'}/{calendar:url_title}/">{calendar:title}</a></h3>
            <p>Calendar: {calendar:calendar_short_name}</p>
            <p>
                From {calendar:event_start_date format="%l, %F %j, %Y - %g:%i%a"} to
                {calendar:event_end_date format="%l, %F %j, %Y - %g:%i%a"}
            </p>
            {if calendar:no_results}
                <p>No events today.</p>
            {/if}
        {/calendar:events}
    {/calendar:hours}
{/exp:calendar:day}