Skip to main content

Fieldtype in Channel:Entries

The Calendar fieldtype allows you to display event data for any entry directly within the EE Channel:Entries template tag. If you're looking to display a chronological list of events (includes your event recurrences), you should use the Calendar:Events tag instead.

For more information about how the Calendar fieldtype works (in the publish page in the EE control panel), refer to the documentation.

{CALENDAR_FIELD_NAME} content {/CALENDAR_FIELD_NAME}

Most of the variables and conditionals listed in the Calendar:Events template tag are available for use here, inside of the {CALENDAR_FIELD_NAME}{/CALENDAR_FIELD_NAME} variable pair. Also available is the {calendar:recurrences}{/calendar:recurrences} variable pair:

<ul>
{calendar:recurrences
date_range_start="today"
date_range_end="3 months"
limit="10"
}
<li>
{calendar:recurrence_start_date format="%F %j, %Y at %g:%i %a"} to
{calendar:recurrence_end_date format="%F %j, %Y at %g:%i %a"}
({calendar:recurrence_count} of {calendar:recurrence_total_results} total)
</li>
{/calendar:recurrences}
{if calendar:recurrences:no_results} {!-- Needs to be AFTER the closing tag --}
<li>No results found for this timeframe.</li>
{/if}
</ul>

This variable pair handles the formatting and display for each recurrence of an event result. For performance reasons, this variable pair can only be used once (can only be used in a single event entry detail page - not a list).

Recurrence Parameters

The following parameters are available for this variable pair:

  • date_range_start="today" - Defines the start of the date range used to generate recurrences. Supports both standard and natural-language date formats.
  • date_range_end="3 months" - Defines the end of the date range used to generate recurrences. Supports both standard and natural-language date formats.
  • limit="10" - Limits the number of recurrences returned.
  • offset="1" - Skips a specified number of recurrences before returning results. Commonly set to 1 to exclude the currently viewed occurrence.

Recurrence Variables

The following variables are available inside this variable pair:

  • {calendar:recurrence_start_date} - Outputs the start date of each recurrence. Format using EE date formatting.
  • {calendar:recurrence_end_date} - Outputs the end date of each recurrence. Format using EE date formatting.
  • {calendar:recurrence_count} - Displays the position of the recurrence within the returned results.
  • {calendar:recurrence_total_results} - Displays the total number of recurrences found within the specified date range.

Conditionals

The following conditional is available after the variable pair:

  • {if calendar:recurrences:no_results}{/if} - Displays its contents when no recurrences are found within the specified date range.

    This conditional must be placed immediately after the closing {/calendar:recurrences} tag (not inside it).

Examples

Single Event

Below is an example of a single event detail page:

{exp:channel:entries
channel="events"
entry_id="{segment_3}"
require_entry="yes"
}
<h3>{title}</h3>
<p>Location: {location}</p>
<p>{description}</p>

{CALENDAR_FIELD_NAME}

<p>Calendar: {calendar:calendar_name}</p>
<p>
{calendar:event_start_date format="%l, %F %j, %Y"}
{if calendar:event_all_day}
(all day)
{if:else}
at {calendar:event_start_date format="%g:%i%a"} -
{if calendar:event_multi_day}
<br />{calendar:event_end_date format="%l, %F %j, %Y at %g:%i%a"}
{if:else}
{calendar:event_end_date format="%g:%i%a"}
{/if}
{/if}
</p>

{if calendar:event_recurs}
<h3>Upcoming occurrences in the next 3 months:</h3>
<ul>
{calendar:recurrences
date_range_start="today"
date_range_end="3 months"
limit="10"
}
<li>
<a href="{path='calendar/day'}{calendar:recurrence_start_date format='%Y/%m/%d'}/">
{calendar:recurrence_start_date format="%F %j, %Y at %g:%i%a"}
</a>
-
<a href="{path='calendar/day'}{calendar:recurrence_end_date format='%Y/%m/%d'}/">
{calendar:recurrence_end_date format="%F %j, %Y at %g:%i%a"}
</a>
</li>
{/calendar:recurrences}
</ul>
{/if}

{/CALENDAR_FIELD_NAME}

<hr />

{if no_results}
<p>Sorry, this event could not be found.</p>
{/if}
{/exp:channel:entries}

List of Events

Below is an example of a list of event entries:

<ul>
{exp:channel:entries
channel="events"
limit="10"
paginate="both"
}
<li>
<strong>{title}</strong>
{CALENDAR_FIELD_NAME}
({calendar:calendar_name})
Starts {calendar:event_start_date format="%l, %F %j, %Y"}
{if calendar:event_all_day}
(all day)
{if:else}
at {calendar:event_start_date format="%g:%i%a"}
{/if}
{if calendar:event_recurs}
(Repeats {calendar:event_recurrence_rule})
{/if}
{/CALENDAR_FIELD_NAME}
</li>
{if no_results}
<li>Sorry, no channel entry results were found.</li>
{/if}
{paginate}
<li>
{pagination_links}
<ul class="pagination">
{first_page}
<li><a href="{pagination_url}" class="page-first">First Page</a></li>
{/first_page}
{previous_page}
<li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
{/previous_page}
{page}
<li{if current_page} class="active"{/if}><a href="{pagination_url}" class="page-{pagination_page_number}">{pagination_page_number}</a></li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="page-next">Next Page</a></li>
{/next_page}
{last_page}
<li><a href="{pagination_url}" class="page-last">Last Page</a></li>
{/last_page}
</ul>
{/pagination_links}
</li>
{/paginate}
{/exp:channel:entries}
</ul>