Status: | effective |
Progress: | 100% |
Version: | 3.0.1+ |
Help:Recurring events
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 as well as events that span across multiple days or other units of time, such as SMWCon.
In Semantic MediaWiki, the dates for a recurring event are defined using the #set_recurring_event
parser function, which is placed on the page that represents the event. All property-value pairs that are created using this function are assigned to a special subobject. This means that the functionality described for subobjects applies to this special form of subobject too. This function additionally takes the following arguments, in any order:
Parameter | Usage | Description |
---|---|---|
(after : )
|
mandatory | Name of the property linking the subobject to the current page, e.g. "Event", "Birthday", etc. See the examples below. It is placed directly after the colon of the parser function. |
property
|
mandatory | of datatype "Date"Holds particular points in time that is being set to all the values |
start
|
mandatory | the first date of the series (can include time) |
end
|
optional | the last date of the series (can include time) |
unit
|
optional | the time unit for the event's frequency; options are 'year ', 'month ', 'week ' and 'day ' (default is 'day ')
|
period
|
optional | the number of time units between one occurrence and the next (default is '1 ')
|
limit
|
optional | the number of recurring events that will be created. Note that this parameter will be ignored if the end parameter is defined (default is 100 according to configuration parameter $smwgDefaultNumRecurringEvents Sets the default number of recurring events if no end date is set)
|
week number
|
optional | 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 (anything from '1 ' to '4 ') , 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
|
optional | any additional dates to include in the series, separated by semicolons (;) |
exclude
|
optional | any dates to exclude from the series, separated by semicolons |
- | optional | Custom property-value pairs may be added as in any subobject. |
Notes[edit]
General[edit]
- If no end date is set, a fixed number of dates is simply saved. This number is defined by and adaptable with configuration parameter
$smwgDefaultNumRecurringEvents
Sets the default number of recurring events if no end date is set, 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 and adaptable with configuration parameter
$smwgMaxNumRecurringEvents
Sets the maximum number of recurring events that can be defined regardless of a given end date, which has a default value of "500
". - If monthly recurring events for the dates 29th to 31st are created and the resulting months for the recurring events do not have such a date like, e.g. February for the 29th (in leap years), 30th and 31st or April for the 31st when the last date of the month will be used, e.g. 28th or 29th (in leap years) for February and 30th for April, etc. This was however not working until it was fixed with Semantic MediaWiki 3.0.1Released on 25 January 2019 and compatible with MW 1.27.0 - 1.31.x..1
- Dates or dates and times must either be set in English, the content language of the wiki or using the ISO date and time format.
Using dates with times[edit]
#set_recurring_event
will set a date only if no times are specified. You can however specify times in the recurring 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.
- Internationalization of dates is incomplete, i.e. "BC", "AD", "PM", "AM" are fixed for all languages.
- If no time is set, e.g. "January 17, 2019" then "January 17, 2019 00:00" is assumed, i.e. internally the default time is "00:00".2
Examples[edit]
Event series[edit]
- Create recurring event
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 |unit=week |period=1 |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 }}
- Query recurring event
The following query would display the recurring events in a calendar using result format "Eventcalendar"An event calendar with different views of displaying days and events on the same page where you created the recurring events.
{{#ask: [[Event::{{PAGENAME}}]] |?Has date |format=eventcalendar }}
Birthday series[edit]
- Create recurring event
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 }} |unit=month |period=12 }}
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|}}} |unit=month |period=12 }}
- Query recurring event
The following query would display the recurring events in an ordered list using result format "Ol"Outputs results as a numbered list, with additional outputs shown in parentheses. on the same page where you created the recurring events.
{{#ask: [[Birthday::{{PAGENAME}}]] |?Has birthday= |format=ol |sort=Has birthday |order=ascending |mainlabel= }}
More examples[edit]
- Demonstration of recurring events - Shows live examples for recurring events on this very wiki
- Demonstration of recurring events - Shows a live example for recurring events on <sandbox.semantic-mediawiki.org>
See also[edit]
- Help page on configuration parameter
$smwgDefaultNumRecurringEvents
Sets the default number of recurring events if no end date is set - Help page on configuration parameter
$smwgMaxNumRecurringEvents
Sets the maximum number of recurring events that can be defined regardless of a given end date - Help page on extension "Semantic Internal Objects"Allows setting of internal objects in Semantic MediaWiki − Explaining how to create recurring events with Semantic Internal Objects which was especially relevant to Semantic MediaWiki 1.8.0Released on 2 December 2012 and compatible with MW 1.17.0 - 1.22.x
(except 1.22.1). and earlier
References
- ^ Semantic MediaWiki: GitHub issue gh:smw:3619
- ^ Semantic MediaWiki: GitHub issue comment gh:smw:3619:455249224