Answers.Body: <p>You access the wrong variable to get to you "compDiscographie" Matrix field. It should be:</p>
  
  <pre><code>{% for block in record.compDiscographie %}
  </code></pre>
  
  <p>Another thing to change here is to add the <code>type</code> parameter, as you probably have other Matrix block types in that field (if not, why did you choose Matrix?):</p>
  
  <pre><code>{% for block in record.compDiscographie.type('myPerformersBlockTypeName') %}
  </code></pre>
  
  <p>Then you should be good. Oh, and you better have that <code>&lt;ul&gt;</code> outside your loop!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-10T12:11:39.670Z
Answers.Text: that did it: {% for block in record.discoArtistes %}. Where discoArtistes is the Matrix handle. Thanks!
Answers.UserDisplayName: jjem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-07T19:22:13.567Z
Answers.LastActivityDate: 2014-11-07T19:22:13.567Z
Answers.UserDisplayName: carlcs
Body: <p>3 sections:</p>
  
  <ul>
  <li>Works</li>
  <li>Discography</li>
  <li>Interpretes</li>
  </ul>
  
  <p><strong>In "Discography"</strong></p>
  
  <p>Matrix block calling entries from "Interpretes"</p>
  
  <p><strong>In "Works"</strong></p>
  
  <p>Relational field pulling entries from "Discography"</p>
  
  <p>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)</p>
  
  <p>Is that possible?</p>
  
  <pre><code>{# 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 %}
  </code></pre>
  
  <p>Tried to be as clear as possible...
  Thanks</p>
  
Tags: <templating><matrix><relations>
Title: How to get related entries from a Matrix block itself related to another section
ThreadText: # How to get related entries from a Matrix block itself related to another section
  
  (Asked by: username_0 on 2014-11-07)
  
  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 %}
  
      <ul>
          <li><a href="{{ record.url }}">{{ record.title }}</a></li>
      </ul>
  
  {# 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
  
  **Tags:** templating, matrix, relations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-07. Score: 1 | Accepted answer
  
  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 `<ul>` outside your loop!
  
  > **Comments:**
  > **username_0**: that did it: {% for block in record.discoArtistes %}. Where discoArtistes is the Matrix handle. Thanks!  
  
  ---
  
  