Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ If you'd like to have a different event timezone default than the app default (u

The default collection for your events is `events`, if you use a different one, publish the config file and then update it via the CP.

For the ICS downloads, you can have a "location" field. By default Events uses a field named 'location' but if you need something different add it to the config:

```php
'collections' => [
'events' => [
'location_field' => 'your_location_field',
],
],
```

## Fieldset

In your collection's blueprint, make sure you have fields like in our sample [fieldset](https://github.com/transformstudios/statamic-events/blob/main/resources/fieldsets/event.yaml).
Expand Down Expand Up @@ -218,7 +228,7 @@ Tag pair that returns the next X event dates.

### Download Links

Single Tag returns a url to the event data and add it to your calendar.
Single Tag returns a url to the event data and add it to your calendar. If there's a "location" field (see config above), it'll get added to the download.

Parameters:

Expand Down
7 changes: 7 additions & 0 deletions config/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

return [
'collection' => 'events',

'collections' => [
'events' => [
'location_field' => 'location',
],
],

'timezone' => config('app.timezone'),
];
11 changes: 10 additions & 1 deletion src/Types/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function toICalendarEvent(string|CarbonInterface $date): ?ICalendarEvent
->startsAt($immutableDate->setTimeFromTimeString($this->startTime()))
->endsAt($immutableDate->setTimeFromTimeString($this->endTime()));

if ($location = $this->event->location) {
if ($location = $this->location($this->event)) {
$iCalEvent->address($location);
}

Expand All @@ -126,6 +126,15 @@ public function toICalendarEvents(): array
];
}

protected function location(Entry $event): ?string
{
$collectionHandle = $event->collectionHandle();

$locationField = config("events.collections.$collectionHandle.location_field", 'location');

return $event->{$locationField};
}

protected function supplement(CarbonInterface $date): ?Entry
{
return unserialize(serialize($this->event))
Expand Down
Loading