{calendar}
Writes a month as a calendar table with its events, or hands over its weeks and days as rows for markup of your own.
Syntax
{calendar}
{calendar '2026-10', data='name', date='field', title='field', link='field', query='month', sunday}
{calendar '2026-10', data='name'} ... {days} ... {events} ... {/events} ... {/days} ... {/calendar}
Parameters
-
month -
The month, written
2026-10. Left out: the request value named byquery, else this month.
Options
-
data -
The events: a
{data}store, a page array or a_datafile, as for{chart}. -
date - The field with an event's date - by default the first field that reads as one.
-
title - The field with an event's text - by default the first other text field.
-
link -
A field with a link for the event - http(s), a page or an anchor; never
javascript:ordata:. -
query -
The request value the links to the months around set, and that picks the month when no parameter is given; default
month. -
sunday - Bare option: the weeks start on Sunday instead of Monday.
Description
{calendar} shows a month. The month is the first parameter ('2026-10'); without it, the request value named by query (?month=2026-11) - the value the links to the month before and after set - and otherwise this month, by padNow, so padNowFreeze holds it still in a test. A month that cannot be read is an error under the strict check.
Written alone it answers a complete table: the month in the caption between links to its neighbours (keeping the other request values, as {pager} does), a column per weekday, a cell per day with its <time> and its events as a list. Today has aria-current="date". A small default look rides along under :where(), so the page's own CSS wins.
The events come from data= - a {data} store, a page array or a _data file. date names the field with the day and title the text; left out, the first field that reads as a date and the first other text field are taken. link makes an event's text a link.
Written as a pair it hands over the weeks as rows instead: $week (the ISO number) and days, in which every day is a row with $date, $day, $weekday, $month, $other (a day of the month before or after), $today, $weekend, $count, $class (other today weekend events, as they apply) and events, the data rows of that date. A store named events hides the day's field of that name - {level:events} reaches it then. For a whole year of values as coloured squares, see {chart 'calendar'}.
Examples
A month with its events
A fixed month as a table; date= and title= name the fields of the events.
{calendar '2026-09', data='agenda', date='when', title='what'}
<?php
$agenda = [
[ 'when' => '2026-09-03', 'what' => 'Team lunch' ],
[ 'when' => '2026-09-14', 'what' => 'Release 2.4' ],
[ 'when' => '2026-09-14', 'what' => 'Retrospective' ],
[ 'when' => '2026-09-25', 'what' => 'Board meeting' ] ];
?>
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
|
||||||
|
||||||
|
||||||
Weeks and days as rows
As a pair the weeks are rows, each with its days, each day with its events.
<table>
<tr><th>Week</th><th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th><th>Su</th></tr>
{calendar '2026-09', data='shifts'}
<tr><th>{$week}</th>{days}<td class="{$class}">{if not $other}{$day}{events}<br><small>{$who}</small>{/events}{/if}</td>{/days}</tr>
{/calendar}
</table>
<?php
$shifts = [
[ 'date' => '2026-09-05', 'who' => 'Anna' ],
[ 'date' => '2026-09-06', 'who' => 'Bram' ],
[ 'date' => '2026-09-19', 'who' => 'Chris' ],
[ 'date' => '2026-09-20', 'who' => 'Anna' ] ];
?>
| Week | Mo | Tu | We | Th | Fr | Sa | Su |
|---|---|---|---|---|---|---|---|
| 36 | 1 | 2 | 3 | 4 |
5 Anna |
6 Bram |
|
| 37 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 38 | 14 | 15 | 16 | 17 | 18 |
19 Chris |
20 Anna |
| 39 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 40 | 28 | 29 | 30 |
See also
- {chart} Draws a chart as inline SVG on the server - 46 kinds, from bars and lines to sankeys, maps of a hierarchy and org charts.
- {timeline} Draws events on a time axis as inline SVG - cards above and below the axis, spans as bars, or one under the other.
- {pager} Page links for a tag written with the page option: first and last, a window round the current page, previous and next.