This document is for an older version of

Calendar

.

View latest version →

Calendar Calendar for ExpressionEngine

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}
1

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>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

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).

The following parameters become available for this variable pair:

  • date_range_start="today" - Specify a date range to display recurrences for. Both standard and easy-to-use text date formatting apply to this parameter.
  • date_range_end="3 months" - Specify a date range to display recurrences for. Both standard and easy-to-use text date formatting apply to this parameter.
  • limit="10" - The maximum number of recurrences to display.
  • offset="1" - The number of recurrences to skip before displays results. You might commonly use this with value of 1 to exclude the currently viewed occurrence from showing up in the results.

The following variables become available for use within this variable pair:

  • {calendar:recurrence_start_date} - Displays the start date of each recurrence for the event. Format using EE date formatting.
  • {calendar:recurrence_end_date} - Displays the end date of each recurrence for the event. Format using EE date formatting.
  • {calendar:recurrence_count} - Displays the display order of each recurrence in the list of recurrence results.
  • {calendar:recurrence_total_results} - Displays the total number of recurrence that are happening for the event within the specified date/time range.

The following conditional becomes available for use after this variable pair:

  • {if calendar:recurrences:no_results}{/if} - Displays its contents if there are no recurrences within the specified timeframe (based on parameters applied to {calendar:recurrences} variable pair). Place this conditional right AFTER your {/calendar:recurrences} closing tag (not inside it) to display your no results message.

Example

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}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

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>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48