\EventsCalendar

Events Plugin Calendar Class

The Events Calendar Class provides variables for Twig to create a dynamic calendar with previous and next links that relate to month and year. This class is also used to display a traditional calendar and form the rows and columns that make up the calendar. It does not calculate dates or manipulate any information. It's simply for displaying a nice calendar page on your Grav website. It is referenced under the onTwigSiteVariables hook in the root events plugin file.

Summary

Methods
Properties
Constants
calendarVars()
twigVars()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

calendarVars()

calendarVars(object  $collection) : array

Twig Calendar Vars

Adds a url to the event header and stores each event in an associative array that can be accessed from calendar.html.twig via year, month, and day params. Here is an example of accessing a particular day on the calendar.

{% for events in calendar.events[calendar.year][calendar.month][day] %}
    {% for event in events %}
         {% if event.title %}
             <div class="event"><a href="{{ event.url }}">{{ event.title }}</a></div>
         {% endif %}
     {% endfor %}
{% endfor %}

Parameters

object $collection

Grav Collection

Returns

array —

Calendar variables for Twig

twigVars()

twigVars(object  $yearParam, object  $monthParam) : array

Twig Display Vars

Returns vars used to navigate and display content in the calendar twig template. Past, present, and future vars are provided to twig for creating custom navigation ui's. Below is a listing of some of the variables that are available.

{% calendar.prevYear %}
{% calendar.nextYear %}
{% calendar.daysInMonth %}
{% calendar.currentDay %}
{% calendar.date %}
{% calendar.year %}
{% calendar.month %}
{% calendar.day %}
{% calendar.next %}
{% calendar.prev %}

Parameters

object $yearParam

Grav URI year: param

object $monthParam

Grav URI month: param

Returns

array —

Twig Array