1

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

1

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!

| improve this answer | |
  • that did it: {% for block in record.discoArtistes %}. Where discoArtistes is the Matrix handle. Thanks! – jjem Nov 10 '14 at 12: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.