Created
May 26, 2016 16:47
-
-
Save michaelrog/22fa9bd8c624195f9ad717cd4366fadd to your computer and use it in GitHub Desktop.
Implementing an event calendar using Matrix Blocks
This file contains 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
{% 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