Skip to content

Instantly share code, notes, and snippets.

View a-am's full-sized avatar

Adam Randlett a-am

View GitHub Profile
@a-am
a-am / venti_event_original_detail.twig
Created January 15, 2016 23:32
Get the original event by ID.
{% set event = craft.venti.getEventById(entry.id) %}
@a-am
a-am / venti_event_detail.twig
Last active August 16, 2016 17:19
Get a specific recurring event not the original.
{% set segments = craft.request.segments %}
{% if segments|length == 3 %}
{% set eid = craft.request.lastSegment %}
{% set event = craft.venti.getEvent(eid) %}
{% else %}
{% set event = craft.venti.nextEvent(entry.id) %}
{% if event == null %}
{% set event = craft.venti.events().id(entry.id).first() %}
{% endif %}
{% endif %}
@a-am
a-am / venti_event_next.twig
Created January 15, 2016 23:29
Get the next recurring event that is happening.
{% set next = craft.venti.nextEvent(event.id) %}
@a-am
a-am / default_calendar.twig
Created January 15, 2016 23:28
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) %}
@a-am
a-am / venti_event_without_repeat.twig
Last active April 13, 2016 22:12
Vent events excluding repeat event only showing original event.
{% set events = craft.venti.allEvents().isrepeat('and',null).find() %}
also
{% set events = craft.venti.events().isrepeat('and',null) %}
@a-am
a-am / venti_events_pagination.twig
Last active January 20, 2016 22:25
Pagination with Venti events.ds
{% set today = now %}
{% set total = craft.venti.allEvents().startDate('and', '>= ' ~ today).total() %}
{% set limit = 5 %}
{% set prev = 1 %}
{% set next = 2 %}
{% set pge = craft.request.getParam('pg') ? craft.request.getParam('pg') : 0 %}
{% set lastPage = "" %}
@a-am
a-am / venti_events_date_span.twig
Last active January 15, 2016 22:44
List of events between now and end of the month.
{% set today = now %}
{% set nextMonth = now | date_modify('first day of next month') %}
{% set events = craft.venti.allEvents().startDate('and', '>= ' ~ now, '<= ' ~ nextMonth).find() %}
@a-am
a-am / venti_events_from_now.twig
Last active January 15, 2016 22:45
Basic List of events from today on.
{% set events = craft.venti.allEvents().startDate('and', '>= ' ~ now).find() %}
@a-am
a-am / venti_events_by_category.twig
Last active January 15, 2016 22:45
Retrieving events by category id.
{% events = craft.venti.allEvents().startDate('and', '>= ' ~ now).relatedTo({targetElement:category.id}).find() %}
@a-am
a-am / search.js
Created January 12, 2016 18:18
Swift Search Methods
tm.Search.init = function () {
if (!$("body").hasClass('search-page')) {
var inputs = [
"st-input-access",
"st-input-header",
"st-input-header-stick",
"st-input-mobile"
];
for (var i = inputs.length - 1; i >= 0; i--) {