Last active
June 23, 2022 12:51
-
-
Save a-am/8b2a7d9b3f164380acae to your computer and use it in GitHub Desktop.
Venti custom calendar output via Twig Helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Array of months withing a specific month and year #} | |
{% set events = craft.venti.allEvents().startDate('and', '>= ' ~ prevMonth, '<= ' ~ nextMonth).find() %} | |
{# Parameters needed for calender output. Venti Events, Month, Year #} | |
{% set params = { "events": events, "month": currentMonth, "year": currentYear } %} | |
{% calendar params as days %} | |
<div> | |
<table> | |
<thead> | |
<tr> | |
{% for item in calendar.head %} | |
<th> | |
<span class="abbr">{{ item.abbr }}</span> | |
</th> | |
{% endfor %} | |
</tr> | |
</thead> | |
<tbody> | |
{% set idx = 1 %} | |
{% for item in days %} | |
{% if idx == 1 %} | |
<tr> | |
{% endif %} | |
{% if item.date is not empty %} | |
<td {% if item.today %}class="today" {% endif %}> | |
<a class='title'> | |
{% if item.today %}<span>today</span>{% endif %} | |
<em> | |
{% if item.day == 1 %}{{ item.date|date("M") }}{% endif %} {{ item.day }} | |
</em> | |
</a> | |
<ul> | |
{% for d in item.events %} | |
<li><a href="{{ d.url }}/{{ d.eid }}">{{ d.title }}</a></li> | |
{% endfor %} | |
</ul> | |
</td> | |
{% else %} | |
<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 %} | |
{% set idx = idx + 1 %} | |
{% if idx > 7 %} | |
</tr> | |
{% set idx = 1 %} | |
{% endif %} | |
{% endfor %} | |
</tbody> | |
</table> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This returns duplicate events on days. It shows events not assigned to that day. Here includes an IF statement to check if the day date matches the event date. Probably not the best way to do it but dont know how else. It still outputs an empty
due to containing events not for that day. I do not know how to fix the issue of events being added to the day item that are not supposed to be on there: