How to get related entries from a Matrix block itself related to another section 3 sections:


Works
Discography
Interpretes


In "Discography"

Matrix block calling entries from "Interpretes"

In "Works"

Relational field pulling entries from "Discography"

In that Work template I need to display the related entry title from Discography (first part of the code below: working) and the related Interpretes selected in Discography (second part of the code: not working)

Is that possible?

{# This first part displays correctly: #}

{% set relatedRecords = craft.entries.section('contenuDiscographie').relatedTo(entry) %}
{% for record in relatedRecords %}

    &lt;ul&gt;
        &lt;li&gt;&lt;a href="{{ record.url }}"&gt;{{ record.title }}&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;

{# And trying to display the related entries from "Interpretes". That's where I'm stuck: #}

    {% for block in entry.compDiscographie %}

        {% set relatedPerformers = craft.entries.section('interpretes').relatedTo(block) %}
        {% for performer in relatedPerformers %}
            {{ performer.title }}
        {% endfor %}

    {% endfor %}

{% endfor %}


Tried to be as clear as possible...
Thanks
You access the wrong variable to get to you "compDiscographie" Matrix field. It should be:

{% for block in record.compDiscographie %}


Another thing to change here is to add the type parameter, as you probably have other Matrix block types in that field (if not, why did you choose Matrix?):

{% for block in record.compDiscographie.type('myPerformersBlockTypeName') %}


Then you should be good. Oh, and you better have that &lt;ul&gt; outside your loop!