Skip to content

Instantly share code, notes, and snippets.

@michaelrog
Created May 26, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelrog/22fa9bd8c624195f9ad717cd4366fadd to your computer and use it in GitHub Desktop.
Save michaelrog/22fa9bd8c624195f9ad717cd4366fadd to your computer and use it in GitHub Desktop.
Implementing an event calendar using Matrix Blocks
{% set blocks = craft.lowblocks.startDate('< foo').endDate('<= bar') %}
{% set ownerIds = [] %}
{% for block in blocks %}
{% set ownerIds = ownerIds|merge(block.ownerId) %}
{% endfor %}
{% set owners = craft.entries.id(ownerIds).indexBy('id') %}
{#
// owners is now an array of the owner EntryModels, keyed by the IDs of the owner entires.
// This makes it easier to call up a specific owner Entry later.
[
1: EntryModel,
2: EntryModel
]
#}
{% for block in blocks %}
{{ block.startDate | date }}
{{ owners[block.ownerId].title }}
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment