Skip to content

Commit

Permalink
Use site to get events (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Apr 17, 2024
1 parent 83a8199 commit 9f31c5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" }}
Expand Down
2 changes: 1 addition & 1 deletion src/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/Tags/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 9f31c5f

Please sign in to comment.