Logo dispositiontools

Mini Cal

Create a simple calendar layout for your elements.

Pass in a set of elements plus a few settings and this plugin will create the month, weeks, and days objects to create simple calendar layouts.

An example:


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

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

{# iterate over the months #}
{% for month in calendar.months %}
<div class="">
  <table>
    <thead>
      <tr>
          <th colspan="7">{{ month.monthStartDate|date("M - Y") }}</th>
      </tr>
      <tr>
      	{# iterate over the day headers #}
        {% for dayHeader in calendar.dayHeaders %}
          <th>{{ dayHeader }}</th>
        {% endfor %}
      </tr>
    </thead>
  <tbody>
  {# iterate over the weeks #}
  {% for week in month.weeks %}
    <tr>
    {# iterate over the days #}
      {% for day in week.days %}
          <td>
          	{# 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 %}
          </td>
      {% endfor %}
    </tr>
  {% endfor %}
  </tbody>
  </table>
</div>
{% endfor %}


This outputs simple table layouts show the elements in a calendar like: