Skip to content

Instantly share code, notes, and snippets.

@a-am
Created January 15, 2016 23:28
Show Gist options
  • Save a-am/ce8efcd50bab2c704e84 to your computer and use it in GitHub Desktop.
Save a-am/ce8efcd50bab2c704e84 to your computer and use it in GitHub Desktop.
Venti's default calendar output for quick calendars.
{# Getting the current month or year if no month or year are passed as url params #}
{% set currentMonth = craft.request.getParam('m') ? craft.request.getParam('m') : "now"|date('n') %}
{% set currentYear = craft.request.getParam('y') ? craft.request.getParam('y') : "now"|date('Y') %}
{# Getting the first day of the currentMonth & currentYear for point of refrence to obtain next month and next year #}
{% set cur = currentYear ~ "-" ~ currentMonth ~ "-1" %}
{% set prevMonth = cur|date_modify("last day of last month")|date('U') %}
{% set nextMonth = cur|date_modify("first day of next month")|date('U') %}
{# Obtaining the events for the calendar #}
{% set events = craft.venti.allEvents().startDate('and', '>= ' ~ prevMonth, '<= ' ~ nextMonth).find() %}
{% set cal = craft.venti.getCal(events,currentMonth,currentYear) %}
{# Output of the calendar #}
<div class="table-box">
{{ cal|raw }}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment