Answers.Body: <p>You can use a <a href="https://craftcms.com/docs/4.x/matrix-blocks.html#querying-matrix-blocks" rel="nofollow noreferrer">Matrix Block Query</a> to query blocks directly, without having to go through the entries. This allows you to get an array of matrix blocks ordered by date, regardless of what entries they belong to. You can limit the query to a specific <a href="https://craftcms.com/docs/4.x/matrix-blocks.html#type" rel="nofollow noreferrer">type</a> or to blocks on a specific <a href="https://craftcms.com/docs/4.x/matrix-blocks.html#fieldid" rel="nofollow noreferrer">field</a> to prevent other matrix fields from appearing in the results. Assuming a block type <code>schedule</code> and a date field <code>week_start</code> on the matrix blocks, the query can look like this:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set schedule = craft.matrixBlocks()
      .type('schedule')
      .orderBy('week_start ASC')
      .all()
  %}
  </code></pre>
  <p>If you need to limit the calendar to specific matrix blocks on specific entries (for example, to build a filter interface), you can use the <a href="https://craftcms.com/docs/4.x/matrix-blocks.html#owner" rel="nofollow noreferrer"><code>owner</code></a> parameter on the query:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set courses = craft.entries()
      .section('courses')
      .title(['Basket weaving', 'Cooking Indian Curry'])
      .ids()
  %}
  
  {% set schedule = craft.matrixBlocks()
      .type('schedule')
      .orderBy('week_start ASC')
      .owner(courses)
      .all()
  %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-06T14:15:53.887Z
Answers.Text: Thank you that helped immensely - got everything working as expected
Answers.UserDisplayName: CreateSean
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-02T16:11:19.537Z
Answers.LastActivityDate: 2023-06-02T16:11:19.537Z
Answers.UserDisplayName: MoritzLost
Body: <p>I'm building a site where the client has courses that run once a week. We'll have several courses and each course will have a matrix with multiple blocks detailing that weeks class.</p>
  <p>What I want to do is output the events in either a calendar (<a href="https://fullcalendar.io/" rel="nofollow noreferrer">Full Calendar</a>) or a list of cards ordered by date of the weekly event.</p>
  <p>Something like this Where basketweaving and cooking indian curry are entries and each week is a matrix block within the entry.</p>
  <ul>
  <li>July 1, 2023 - Basket weaving -An introduction (week 1)</li>
  <li>July 3, 2023 - Cooking Indian Curry - different types (week 1)</li>
  <li>July 7, 2023 - Basket weaving - making your first basket (week 2)</li>
  <li>July 8, 2023 - Cooking Indian Curry - your first Vindaloo (week 2)</li>
  <li>July 14, 2023 - Basket weaving - Intermediate techniques (week 3)</li>
  <li>July 16, 2023 - Cooking Indian Curry - taming the spice (week 3)</li>
  </ul>
  <p>Is it possible to output and mix matrix blocks across entries?</p>
  
Tags: <templating><matrix>
Title: Events with sub-events in a matrix field - display as a calendar (combined with other events)
ThreadText: # Events with sub-events in a matrix field - display as a calendar (combined with other events)
  
  (Asked by: username_0 on 2023-06-01)
  
  I'm building a site where the client has courses that run once a week. We'll have several courses and each course will have a matrix with multiple blocks detailing that weeks class.
  
  What I want to do is output the events in either a calendar ([Full Calendar](https://fullcalendar.io/)) or a list of cards ordered by date of the weekly event.
  
  Something like this Where basketweaving and cooking indian curry are entries and each week is a matrix block within the entry.
  
  * July 1, 2023 - Basket weaving -An introduction (week 1)
  * July 3, 2023 - Cooking Indian Curry - different types (week 1)
  * July 7, 2023 - Basket weaving - making your first basket (week 2)
  * July 8, 2023 - Cooking Indian Curry - your first Vindaloo (week 2)
  * July 14, 2023 - Basket weaving - Intermediate techniques (week 3)
  * July 16, 2023 - Cooking Indian Curry - taming the spice (week 3)
  
  Is it possible to output and mix matrix blocks across entries?
  
  **Tags:** templating, matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-06-02. Score: 2 | Accepted answer
  
  You can use a [Matrix Block Query](https://craftcms.com/docs/4.x/matrix-blocks.html#querying-matrix-blocks) to query blocks directly, without having to go through the entries. This allows you to get an array of matrix blocks ordered by date, regardless of what entries they belong to. You can limit the query to a specific [type](https://craftcms.com/docs/4.x/matrix-blocks.html#type) or to blocks on a specific [field](https://craftcms.com/docs/4.x/matrix-blocks.html#fieldid) to prevent other matrix fields from appearing in the results. Assuming a block type `schedule` and a date field `week_start` on the matrix blocks, the query can look like this:
  
  ```twig
  {% set schedule = craft.matrixBlocks()
      .type('schedule')
      .orderBy('week_start ASC')
      .all()
  %}
  
  ```
  
  If you need to limit the calendar to specific matrix blocks on specific entries (for example, to build a filter interface), you can use the [`owner`](https://craftcms.com/docs/4.x/matrix-blocks.html#owner) parameter on the query:
  
  ```twig
  {% set courses = craft.entries()
      .section('courses')
      .title(['Basket weaving', 'Cooking Indian Curry'])
      .ids()
  %}
  
  {% set schedule = craft.matrixBlocks()
      .type('schedule')
      .orderBy('week_start ASC')
      .owner(courses)
      .all()
  %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you that helped immensely - got everything working as expected  
  
  ---
  
  