\Grav\PluginEventsPlugin

Grav Events

The Events Plugin provides Event Listings and Calendars for your Grav powered website. This plugin searches each page for event: frontmatter and then sets a custom taxonomy named type to event. It also sets a repeating and frequency taxonomy to build more intricate collections. The event_repeat taxonomy will take a string in the format MTWRFSU and the event_freq taxonomy will take daily, weekly, monthly, or yearly. These taxonomies are automatically added and processed by the plugin.

Below is a sample of what an event: front matter section would look like in a Grav page. Note: You can used the event template and yaml included in the plugin for use in the admin plugin or add event: frontmatter to any page of your choice. This plugin is smart enough to add any page to @taxonomy.type as an event so you can build collections off of pages taxonomized with the event taxonomy type.

event:
    start: 01/01/2015 6:00pm
    end: 01/01/2015 7:00pm
    repeat: MTWRFSU
    freq: weekly
    until: 01/01/2020
    location: Raleigh, NC
    coordinates: 35.7795897, -78.6381787

If you use the Admin pluin, the events plugin will automatically geo-decode the location field to a set of coordinates so that you don't have too.

PHP version 5.6+

Summary

Methods
Properties
Constants
getSubscribedEvents()
onPluginsInitialized()
onTwigTemplatePaths()
onPagesInitialized()
onGetPageTemplates()
onTwigSiteVariables()
onAdminSave()
No public properties found
No constants found
No protected methods found
$now
$events
$calendar
N/A
No private methods found
No private properties found
N/A

Properties

$now

$now : object

Current Carbon DateTime

Type

object — Carbon DateTime

$events

$events : object

Events/Events Class

Processes pages for event: frontmatter and then inserts repeating and reoccuring events into Grav Pages with updated dates, route, and path.

Type

object — Events

$calendar

$calendar : object

Events/Calendar Class

Provides data to be used in the calendar.html.twig template.

Type

object — Calendar

Methods

getSubscribedEvents()

getSubscribedEvents() : array

Get Subscribed Events

Returns

array

onPluginsInitialized()

onPluginsInitialized() : void

Initialize plugin configuration

Determine if the plugin should run and set the custom taxonomies to store event information in. We also initialize the Events and Calendar class that this plugin utilizes and then we start intercepting Grav hooks to build our events list and insert any vars we need into the system.

onTwigTemplatePaths()

onTwigTemplatePaths() : void

Add current directory to twig lookup paths.

Add the templates directory to the twig directory look up path so we can load our page templates. These are overridable by the theme and are only meant as a starting point.

onPagesInitialized()

onPagesInitialized() : void

Add repeating and reoccuring events as Grav pages

Repeating Events: events the tile horizontally in a week MTWRFSU Reoccuring Events: events that tile vertically through daily, weekly, monthly, yearly

The Events/Events class searches for pages with event: frontmatter and processes these into new Grav pages as needed. This is a dynamic operation and does not add new physical pages to the filesystem.

onGetPageTemplates()

onGetPageTemplates(\RocketTheme\Toolbox\Event\Event  $event) : void

Association with page templates

Parameters

\RocketTheme\Toolbox\Event\Event $event

onTwigSiteVariables()

onTwigSiteVariables() : void

Set needed variables to display events

For the calendar page, we load the appropriate js and css to make the calendar work smoothly as well as add the appropriate calendar twig variables.

onAdminSave()

onAdminSave(\RocketTheme\Toolbox\Event\Event  $event) : void

Process Event Information

This hook fires a reverse geocoding hook for the location field on single events.

Parameters

\RocketTheme\Toolbox\Event\Event $event