Integration with Eventbrite API to read information and return it in a variable.
This plugin requires Craft CMS 4.0.0 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require adigital/eventbrite
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Eventbrite.
The following screenshot of the plugin settings page gives an indication of how it works - you need to provide an Eventbrite API key and organisation ID, and these settings are only editable by admins on environments where the allowAdminChanges
setting is enabled.
There's also a settings page which can be accessed by non-admin accounts with the right permission in all environments regardless of the allowAdminChanges
setting. This page enables users to optionally specify additional event IDs not set up by their organisation to return along with their organisation's events. See screenshots of this settings page and permission below:
Once configured, data is returned through the plugin variable using the following methods:
craft.eventbrite.allEvents([expansions] = null, sort = true, time_filter = "current_future", unlistedEvents = false, status = "live")
This method returns all events planned by the organisation and specified by the additional event IDs setting. The expansions
parameter should be a Twig array where the values correspond to the additional models that can be returned when querying data from the API. You can see the expansions that are available for events in the documentation. The sort
parameter will sort events by date by default when organisation and other events are being combined. The time_filter
parameter defaults to current and future events, but can also be past
or all
. The unlistedEvents
parameter can be set as true
if you want to return unlisted events. Finally, status
defaults to only retrieve live
events, but can also be set as draft
, started
, ended
, completed
, or canceled
.
craft.eventbrite.organisationEvents([expansions] = null, time_filter = "current_future", unlistedEvents = false, status = "live")
This method returns only events planned by the organisation, with the parameters working in the same way as the allEvents
method.
craft.eventbrite.otherEvents([expansions] = null, sort = true, time_filter = "current_future", unlistedEvents = false)
This method returns only events specified by the 'Other Event Ids' setting, with the parameters working in the same way as the allEvents
method.
craft.eventbrite.eventById(eventId, [expansions] = null, fullDescription = true, unlistedEvent = false)
This method returns a single event by its ID, which should be the numeric ID for the event in Eventbrite. Expansions are specified as described above and the full HTML description for the event can be optionally returned and accessed with eventVariable['htmlDescription']['description']
.
organisationVenues()
This method returns all the venues belonging to the organisation specified in the plugin settings.
venueById(venueId)
This method returns a venue by its ID, which should be the numeric ID for the venue in Eventbrite.
venueEvents(venueId, [expansions] = null, unlistedEvents = false, status = "live" onlyPublic = "true")
This method returns only events held at the venue specified by the venueId
parameter, with the other parameters working in the same way as the allEvents
method, and the additional onlyPublic
parameter that states whether the events returned should be filtered by whether they are public.
As the plugin reads live data from the Eventbrite API, you should wrap any use of the variable in your Twig templates within Craft cache
tags to reduce your calls to the API and improve page load times.
Things to do, and ideas for potential features:
- Add methods to write back to Eventbrite so purchasing of tickets can be completed without going offsite
- Explore use of other API methods to expand data returned and possibly add more event stats to Craft
Brought to you by Mark @ A Digital