From 9f31c5ffb5d44e6844325112327c31c6fe52c640 Mon Sep 17 00:00:00 2001 From: Erin Dalzell Date: Wed, 17 Apr 2024 10:07:40 -0700 Subject: [PATCH] Use `site` to get events (#91) --- DOCUMENTATION.md | 7 ++++--- src/Events.php | 2 +- src/Tags/Events.php | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 1c84484..d317b77 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -63,9 +63,11 @@ days: ### Tags (Between, Calendar, Download Link, In, Today, Upcoming) -Standard Entries are returned, with some extra data: +**Common Parameters** -**Additional Variables** +All of the above (except Download Link) have a `site` parameter you can pass the handle of the site to get the events from. It defaults to your default site. **Note**: if you use Livewire you may need to set this from Antlers, using `{site:handle}` + +**Additional Variables** (normal entry data is available) * `start` - Carbon date/time of the occurrence start * `end` - Carbon date/time of the occurrence end. Note if it's an all date event this will be set to 11:59:59pm @@ -82,7 +84,6 @@ If you want to paginate the results, add `paginate="xx"`, where `xx` is the numb The output is identical to the `collection` tag [pagination](https://statamic.dev/tags/collection#pagination). - *Example* ``` {{ events:between collection="events" from="Jan 1 2022" to="March 31 2022" paginate="2" }} diff --git a/src/Events.php b/src/Events.php index 2b82a94..c95bd1d 100644 --- a/src/Events.php +++ b/src/Events.php @@ -100,7 +100,7 @@ public function pagination(int $page = 1, int $perPage = 10): self return $this; } - public function site(string $handle): self + public function site(?string $handle = null): self { $this->site = $handle; diff --git a/src/Tags/Events.php b/src/Tags/Events.php index 7d2ab64..0b74676 100755 --- a/src/Tags/Events.php +++ b/src/Tags/Events.php @@ -132,6 +132,7 @@ private function generator(): Generator Generator::fromCollection($this->params->get('collection', 'events')); return $generator + ->site($this->params->get('site')) ->sort($this->params->get('sort', 'asc')) ->when( value: $this->parseTerms(),