1

Ok, my mind is about to implode with this… any help on template syntax very welcome!

I have 2 Sections: ‘artists’ and ‘schedules

In the ‘schedules’ section I have a Matrix field called ‘stageSchedule’, with a Block type called ‘dayOfEvent

In that Block type I have a Super Table field called ‘schedule’. - breakdown....

  • schedules (Section)
    • stageSchedule (Matrix) > dayOfEvent (Block)
      • schedule (Block field (Super Table)) - ST

In ‘schedule (ST)’ I have a date field called ‘timeOn’, which is when the artist is due to be on stage. I thought I could get this information from ‘schedule (ST)’ by having an ENTRIES field called 'act' (in the same ST field) which is linked to a specific artist from the ‘artists' section.

What I want to do... On the individual ‘Artist Bio’ pages I want to display what time they’re going to be on stage by pulling that information from ‘schedule > stageSchedule (M) > dayOfEvent (B) > schedule (ST) > ‘timeOn’.

I have tried every which way but I either get an error or nothing at all :/

I hope that makes sense... Thanks to anyone who can work this one out!

EDIT

As a test I created a Super Table field on it's own (not within Matrix) and got the data correctly using this:

{% set reverseRelatedElements = craft.superTable.getRelatedElements({
    relatedTo: {
      targetElement: entry,
      field: 'testTimes.artist' // Super Table Field
    },
    section: 'schedules’
  }) %}

  {% for relatedEntry in reverseRelatedElements %}
    {{ relatedEntry.testTimes.timeon|datetime('H:i') }}
    {{ relatedEntry.testTimes.timeOff|datetime('H:i') }}
  {% endfor %}

So basically I need to do the same but target a Super Table field nested in a Matrix field? Here's an image...

enter image description here

1

I didn't test it yet but it should like this :

{% set entries = craft.entries().section('schedules').all() %}
{% for entry in entries %}
{% for block in entry.stageSchedule : %}
    {% if block.type == 'yourblocktype' : %}
         {% for item in block.schedule %}
            {{ item.timeOn }}
         {% endfor %}
    {% endif %}
{% endfor %}
{% endfor %}

I assume there is only one entry in schedules sections. Please be remind block type is different with block name. Hope this help.

| improve this answer | |
  • Hi @aodihis, there are more than one entries because there are more than one stages. I have tried your solution as follows but I get an error (Key "stageSchedule" for array with keys "0, 1" does not exist.). {% set entry = craft.entries().section('shedules').all() %} {% for block in entry.stageSchedule %} {% if block.type == 'dayOfEvent' %} {% for item in block.schedule %} {{ item.timeOn|datetime('short') }} {% endfor %} {% endif %} {% endfor %} – Martin Apr 26 at 18:23
  • @Martin , I see so we need to do a loop for each entry. I have updated the answer. – aodihis Apr 27 at 13:48
  • Hi @aodihis, thank you but I can't see how your solution is looking for the reverse relation with 'artist'? --- I have edited my post with more information if it helps? – Martin Apr 27 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.