Venti 2

Documentation

Calendars

Venti2 allows you to output custom markup calendar. By grabbing the set of events you want you can pass them along to our calendar Twig method to output the custom calendar.


{# Array of months withing a specific month and year #}
{% set events = craft.venti.events.between(monthStartDate,monthEndDate) %}
{# Calendar parameters #}
{% set params = { 'events':events, 'month': month, 'year':year, 'startDOW': dow } %}
{# Calendar output #}
{% calendar params as days %}

Calendar Parameters#


{% set params =
    {
        'events':events,
        'month': month,
        'year':year,
        'startDOW': dow,
        'locale':'en_us'
    }
%}

events

The range of events the calendar will display. If you use between provide the very end of previous month and start of next month.

{% set events = craft.venti.events.between(monthStartDate,monthEndDate) %}

month 1 - 12

The month the calendar will display. (1 = January)

year 2016

The 4 digit year the calendar will display.

startDOW 0 - 6

The day of the week the calendar starts with. (0 = Sunday)

locale es_us

The locale the calendar headings will output as.



Calendar Day Events Attributes#

These items are available as you output every day.


{# Paramaters provided through variable as shown above. #}
{% calendar params as days %}
{% for day in days %}
    {% for event in day.events %}
    {% endfor %}
{% endfor %}

dateString

Quick access to the event startDate.

dateParts[day,month,year]

Access to the start date's day, month & year.

eid

Quick access to the event eid.

event

Access to the full event model. Event Model

id

Quick access to the event id.

slug

Quick access to the event slug.

title

Quick access to the event title.

url

Quick access to the event url.



Calendar Output#


head

This is used to output the day of the week names. When looping through the head you have access to different abbreviations of the days of the week.

{
    narrow: 'S',
    short: 'Su',
    abbr: 'Sun',
    wide: 'Sunday'
}
{% set params =
{% set events = craft.venti.events.between(prevMonth,nextMonth) %}
{% set params = {
    "events": events,
    "month": currentMonth,
    "year": currentYear,
    "startDOW": 0
    }
%}
{% calendar params as days %}
<div>
    <table>
        <thead>
            <tr>
                {# Output the day of the week names using the 'abbr' abbreviation. #}
                {% for item in calendar.head %}
                    <th>
                        <span class="abbr">{{ item.abbr }}</span>
                    </th>
                {% endfor %}
            </tr>
        </thead>
        <tbody>
             {# Setting an index so we know when to output a new row. #}
            {% set idx = 1 %}
            {# Looping through each day. #}
            {% for item in days %}
                {# Because this is the start of the row we output a opening container element. #}
                {% if idx == 1 %}
                    <tr>
                {% endif %}
                {# Outputting each day in this week if it is not empty. #}
                {% if item.date is not empty %}
                    {# If day is today give output extra content to let user know. #}
                    <td {% if item.today %}class="today" {% endif %}>
                        <a class='title'>
                            {% if item.today %}<span>today</span>{% endif %}
                            <em>
                                {# If today is first day of the month output the month name with day number otherwise output the day number. #}
                                {% if item.day == 1 %}{{ item.date|date("M") }}{% endif %} {{ item.day }}
                            </em>
                        </a>
                        <ul>
                            {# Looping through and outputting each event for today. #}
                            {% for d in item.events %}
                                 <li><a href="{{ d.url }}">{{ d.title }}</a></li>
                            {% endfor %}
                        </ul>
                    </td>
                {% else %}
                    {# Output day number on empty days. #}
                    <td>
                        <a class='title'><em>{{ item.day }}</em></a>
                        {% if item.date is not empty %} {{ item.date|date('D M d Y') }} {% endif %}
                    </td>
                {% endif %}
                {# Increment the index. #}
                {% set idx = idx + 1 %}
                {# If the index is greater than 7 set the week closing element and reset index to start a new week. #}
                {% if idx > 7 %}
                    </tr>
                    {% set idx = 1 %}
                {% endif %}
            {% endfor %}
        </tbody>
    </table>
</div>
%}