Add publish_date and expiry_date support

This commit is contained in:
Ruben 2026-05-11 20:18:02 +02:00
parent a22281c896
commit 4448798bf5
6 changed files with 148 additions and 3 deletions

View file

@ -55,9 +55,44 @@ Returns flat key-value array with a special `_raw` key containing the full parse
| `redirect` | string | — | External URL (list items can redirect) |
| `feed` | bool | `false` | Enable Atom feed on list pages (`feed.xml`) |
| `author` | string | title | Atom feed author name (falls back to page title) |
| `publish_date` | string (YYYY-MM-DD) | — | Earliest date content is visible |
| `expiry_date` | string (YYYY-MM-DD) | — | Last date content is visible (inclusive) |
| `plugins` | string | — | Comma-separated page-level plugin names |
### Settings Section
## Visibility (Scheduling)
Content can be scheduled using `publish_date` and `expiry_date`. Both fields are optional — when absent, content is always visible.
When set:
- **`publish_date`** — Content becomes visible on this date (inclusive). Before this date it is treated as non-existent.
- **`expiry_date`** — Content remains visible through this date (inclusive). After this date it is treated as non-existent.
Invisible content is:
- Hidden from list views (`buildListItems()`)
- Excluded from navigation (`buildNavigation()`)
- Returns 404 on direct access (page and list cases in `router.php`)
- Omitted from Atom feeds automatically (feeds use the filtered items array)
The check uses UTC (`gmdate('Y-m-d')`) so behavior is consistent regardless of server timezone.
These fields can be overridden per-language in `[en]` sections via the language plugin:
```ini
title = "Event"
publish_date = "2025-10-01"
expiry_date = "2025-10-07"
[no]
title = "Arrangement"
publish_date = "2025-10-01"
expiry_date = "2025-10-08"
```
### `isVisible(?array $metadata): bool`
Pure function in `helpers.php`. Returns `true` when content should be visible, `false` otherwise. Accepts nullable metadata — returns `true` for `null` (no metadata file = always visible).
## Settings Section
```ini
[settings]