This document is for an older version of

Calendar

.

View latest version →

Calendar Calendar for ExpressionEngine

Calendar:Week template tag

The Calendar:Week loop outputs a one week calendar list showing a specific weeks events. It's a shortcut to using the complex Calendar:Cal function. Unlike most ExpressionEngine tags, the {exp:calendar:week}{/exp:calendar:week} tags alone will output a pre-templated display. Using the parameters and variables below, you can filter and format the results further. Defaults to displaying events for current week.

{exp:calendar:week} content {/exp:calendar:week}
1

Parameters

site_id=

site_id="1"

If using MSM, you can specify a Site ID in this parameter to filter entries down to that site.

calendar_id=

calendar_id="1|3"

This parameter allows you to display specific calendars by specifying their entry 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_name=

calendar_name="soccer|baseball|dodgeball"

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

event_id=

event_id="23|77"

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

event_name=

event_name="best_event_evar|christmas|pie_day"

This parameter allows you to display specific events by specifying their short_names (entry url_title). You can hardcode a short_name, pass it through an embed, or grab it from the URI. Separate multiples with the pipe character.

first_day_of_week=

first_day_of_week="0"

By default, Calendar considers Sunday as the first day of the week. This parameter allows you to override that by specifying the numeric value of a weekday (ex: Sunday = 0, Monday = 1, etc).

date_range_start=

date_range_start="2010-01-31"

This parameter allows you to specify a specific week to display events for. For weeks, you would normally specify the starting day of the week, so usually a Sunday. However, if you specify a weekday within a week range, the Week function will load the week the day you specify is in. If this parameter is NOT specified, then the current week is displayed. Both standard and easy-to-use text date formatting apply to this parameter.

enable=

enable="categories|category_fields|custom_fields|member_data|pagination"

By default, this function does not grab any advanced channel data in order to improve performance. However, opposite to the EE Channel module's disable parameter, this parameter allows you to enable some or all of those features when you need them. Separate multiples with the pipe character. Options are: categories, category_fields, custom_fields, member_data, and pagination.

Variables

Most of the variables listed in Calendar:Events are available for use here. Formatting variables are not needed as the Calendar:Week loop will do that for you. However, should you need to use any, all relevant variables from Calendar:Cal (prepended with week_) are available for use here.

Conditionals

Most of the conditionals listed in Calendar:Events are available for use here. Formatting conditionals are not needed as the Calendar:Week loop will do that for you. However, should you need to use any, all relevant conditionals from Calendar:Cal (prepended with week_) are available for use here.

Examples

Easy

This single set of code will output a Weekly list of events for you. This is thanks to the preloaded template pack included with Calendar. The {exp:calendar:week}{/exp:calendar:week} tags act almost like an {events}{/events} variable pair for formatting the events (see Calendar:Events Documentation for list of available variables and conditionals):

{exp:calendar:week
  {if segment_3}
    date_range_start="{segment_3}-{segment_4}-{segment_5}" 
    date_range_end="{segment_3}-{segment_4}-{segment_5}"
  {/if}
}
  <div class="event">
    <a href="{path='calendar/events'}/{event_id}/">
      {event_title}
    </a>
    {if event_all_day}
      (All day!)
    {if:else}
      {event_start_date format="%g:%i%a"} - 
      {event_end_date format="%g:%i%a"}
    {/if}
  </div>
{/exp:calendar:week}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Advanced

If you’re interested in working the code from scratch, you’ll need to use the full Calendar:Cal function to generate the code:

{exp:calendar:cal 
  enable="custom_fields" 
  pad_short_weeks="y" 
  {if segment_3 == ''}
    date_range_start="0 weeks begin"
  {/if}
  {if segment_3 != ''}
    date_range_start="{segment_3}-{segment_4}-{segment_5}"
    date_range_end="{segment_3}-{segment_4}-{segment_5}"
  {/if}
}
  {display_each_week}
    <div class="header">
      <div style="float: left; width: 20%;"> 
        <a href="{path='calendar/week'}/{prev_week format="%Y/%m/%d"}/">Last Week</a>
      </div>
      <div style="float: left; width: 60%; text-align: center;">
        <h1>Week of {date format="%l, %F %d, %Y"}</h1>
      </div>
      <div style="float: right; text-align: right; width: 20%;">
        <a href="{path='calendar/week'}/{next_week format="%Y/%m/%d"}/">Next Week</a>
      </div>
      <br style="clear: both;" />
    </div>
    {display_each_day}
    <div class="day">
      <h2>
        <a href="{path='calendar/day'}/{date format="%Y/%m/%d"}/">
          {date format="%l, %F %j, %Y"}
        </a>
      </h2>
      <ul>
      {if day_event_total == 0}
        <li>No events today.</li>
      {/if}
      {events}
        <li class="event">
          <a href="{path='calendar/events'}/{event_id}/">
            {event_title}
          </a>
          {if event_all_day}
            (All day!)
          {if:else}
            {event_start_date format="%g:%i%a"} - 
            {event_end_date format="%g:%i%a"}
          {/if}            
        </li>         
      {/events}
      </ul>
    </div>   
    {/display_each_day}
  {/display_each_week}
{/exp:calendar:cal}
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