Help:Recurring events

Jump to: navigation, search
Recurring events
Silently set recurring semantic data in a wiki page
Further Information
Provided by: Semantic MediaWiki
Minimum version: 1.5.0
Maximum version: still supported
Function: yes
Tag: no
Name: #set_recurring_event
Table of Contents

A recurring event is any event that occurs more than once, according to a pre-defined rule: examples are weekly meetings, anniversaries and birthdays. In Semantic MediaWiki, the dates for a recurring events are defined using the #set_recurring_event parser function, which is placed on the page that represents the event. This function takes the following arguments, in any order:

  • property - the Date property that is being set to all the values
  • start - the first date of the series (can include time)
  • end - the last date of the series (optional, can include time)
  • unit - the time unit for the event's frequency; options are 'year', 'month', 'week' and 'day' (optional - default is 'day')
  • period - the number of time units between one occurrence and the next (optional - default is 1)
  • week number - if the unit is set to 'month', this parameter indicates that the event happens on a certain numbered day of the week in each month, like the 1st Thursday of every month. A negative value (anything from -1 to -4) indicates that the event happens on the nth last such day of the month, such as the 2nd-to-last Monday. The actual day of the week is defined by the start date.
  • include - any additional dates to include in the series, separated by semicolons (;) (optional)
  • exclude - any dates to exclude from the series, separated by semicolons (optional)

If no end date is set, a fixed number of dates is simply saved; this number is defined by the variable $smwgDefaultNumRecurringEvents, which has a default value of 100. There is also a maximum number of dates that can be saved using this function, regardless of the start and end date specified. This number is set by the variable $smwgMaxNumRecurringEvents, which has a default value of 500. Both values can be modified in one's LocalSettings.php file.


The following call would create subobjects with an Event property linking to the current page, and set the Has date property for each subobject to Mondays at 7:00 pm between January 4, 2010 and June 8, 2011, with the exception of March 15, 2010 and March 22, 2010, both of which are replaced by the following Tuesday at different times:

{{#set_recurring_event: Event
|property=Has date
|start=January 4, 2010 7:00 pm
|end=June 8, 2011
|include=March 16, 2010 6:00 pm;March 23, 2010 5:00 pm
|exclude=March 15, 2010 7:00 pm;March 22, 2010 7:00 pm

The following call creates subobjects with a Birthday property linking to the current page, and a Has birthday property for all birthdays of a person, starting with his or her date of birth; it is done by picking up the date entered on a page for the defined "Property:Has date of birth":

{{#set_recurring_event: Birthday
|property=Has birthday
|start={{#show:{{PAGENAME}}|?Has date of birth}}

If such a call were placed in a template, and the date of birth were entered as a template field, the code could be made even simpler:

{{#set_recurring_event: Birthday
|property=Has birthday
|start={{{Date of birth|}}}

Note about using dates with times

#set_recurring_event will set a date only if no times are specified. You can specify times in the recurring event however you can specify a time with the event as well. Two important items to note:

  • Exclude parameters must also specify the time. When #set_recurring_event evaluates it will compare the excluded times array to the calculated recurrences, and is specific to the time. If you specify a start value with a time of 7:00 pm, the exclude must also reference this. If you are working with forms it is convenient to request the time in a separate field and then automatically add it to the start as well as exclude parameters for the user. You may also consider adding it to the include parameters.
  • The end parameter will also honor a time value, and the recurrences will end at that time, instead of at midnight of the date specified.

Live examples

See also

This documentation page applies to all SMW versions from 1.5.0 to the most current version.
      Other languages: zh-hans

Help:Recurring events en 1.5.0