Logo dispositiontools

Minical template functions

Getting started

Creating the Minical calendar object is very easy.

  • Firstly get all the elements you'd like to layout in a calendar.
  • Create the options object
  • Create the calendar object

{# Get your elements #}
{% set elements = craft.entries.section('events').all() %}

{# Create the settings object  #}
{% set calOptions = {
  elements: elements,
 } %}

{# create the calendar object #}
{% set calendar = craft.minical.cal( calOptions ) %}

Now you have the calendar object you can iterate over the months, weeks, days and daily elements and style however you'd like.

{# iterate over the months #}
{% for month in calendar.months %}
<div class="">
          <th colspan="7">{{ month.monthStartDate|date("M - Y") }}</th>
      	{# iterate over the day headers #}
        {% for dayHeader in calendar.dayHeaders %}
          <th>{{ dayHeader }}</th>
        {% endfor %}
  {# iterate over the weeks #}
  {% for week in month.weeks %}
    {# iterate over the days #}
      {% for day in week.days %}
          	{# show the date if the cell in the table is an actualday  #}	
            {% if not day.blank %}
            {{ day.dayDate|date("d") }}
            {% endif %}
			{# Show a symbol if the day has elements  #}	
            {% if day.hasElements %} ! {% endif %}
			{# iterate over the elements in that day. #}
			{# These elements are the full element array item that was originally given in the settings object  #}	
            {% for element in day.elements %}
              <a href="{{ element.url }}">{{ element.title }}</a>
            {% endfor %}
      {% endfor %}
  {% endfor %}
{% endfor %}


If you just pass Minical a set of elements it will look for the first and last occurrences and then create the months to cover all of those dates.

Custom starting and ending months

You can choose your own starting and ending dates with the parameters

startDateString and endDateString

These take any string that can be parsed by php strtotime.

{% set calOptions = {
  endDateString: '2020-12-31'
 } %}

Change the week starting date.

Minical defaults to the week starting on a Monday. You can choose your own starting date with the parameter:


This accepts a integer between 0 and 6.

{% set calOptions = {
 } %}

Day title format

The plugin default is show the day titles as three letters long. You can choose another format using the dayTitleFormat parameter. This accepts any DateTime format string.

Ie to get the full day names use "l" (Lowercase L).

{% set calOptions = {
 } %}

Date field

The plugin defaults to checking the postDate of the element. If you are using a different date field you can use the dateField parameter.

This fields needs to be a DateTime type field.

{% set calOptions = {
 } %}