TIP

WE'RE HIRING! 💼

The Solspace team is expanding! If you love Craft CMS and you’re looking for an exciting full-time remote position working on software development for the Freeform and Calendar plugins for Craft and more, we’d love to hear from you!

Check Out Job Listing!

calendar.calendars function

The calendar.calendars template function fetches a list of calendars based on some or no criteria.

Parameters

  • id #
    • The unique calendar ID
    • Can be passed as an array of ID's - [1, 2, 3]
    • Use "not 1,2,3" to filter out calendars which don't have an ID of 1, 2 or 3
    • Use "!= 3" to filter out calendars which don't have an ID of 3
  • name #
    • same usage as listed above for id
  • handle #
    • same usage as listed above for id
  • color #
    • a hex value of the color, e.g - #FFFFFF
  • orderBy #
    • Valid orderBy attributes are id, name, handle and color
  • sort #
    • Options are ASC or DESC
  • limit #
    • An int limiting the result count

Usage in Templates

{% set calendars = craft.calendar.calendars({
  orderBy: "name",
  sort: "asc"
}) %}

{% for calendar in calendars %}
  <div style="color: {{ calendar.color }};">
    {{ calendar.name }}
  </div>
{% endfor %}
1
2
3
4
5
6
7
8
9
10
Last Updated: 2/3/2020, 5:06:34 PM