We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Relate in Replicator?

Peter Emil van den Berg April 24, 2018 by Peter Emil van den Berg

Just a quick question before I need to sleep... but when I don't ask this one it'll haunt me in my dreams :)

Client wants to show an overview of productions on a page. They like to do this manually. The relate field is perfect for this. But they want to have some extra fields to go with this. I thought a Replicator would do fine, but when I create one with the fields collection and text the output doesn't show the values of the linked production. This think this is because its a part of a replicator. When just putting linked_production: 8613455b-5a5e-4aed-88c4-43ff58bd8cab in the front matter of the index.md all values show fine, but not when its a part of a replicator set.

How do I combine the values of the linked production (hero-image, url, title) with those in the replicator (label) in the template?

This is the code:

the index.md

title: productions
linked_productions:
  -
    type: item
    linked_production: a7b81196-b481-44c7-9cfa-e810714b66d9
    label: It does go well with chicken
  -
    type: item
    linked_production: 8613455b-5a5e-4aed-88c4-43ff58bd8cab
    label: Thanks Peter

the template

...
<section>
    <h2>{{ season }} 2017 – 2018</h2>
    <ul class="grid-view">
      {{# we're showing the productions the way they are sorted in the cp #}}

      {{ relate:linked_production }}
        <li class="item {{ slug }} new index-{{ index }}">
          <a href="{{ url }}">
            <div class="img-wrapper">
              <img src="{{ hero_image }}" />
            </div>
            <h4>{{ title | lower }}</h4>
          </a>
        </li>
      {{ /relate:linked_production }}
      <div class="cta">{{ label }}</div>
    </ul>
  </section>
...
Answered by Peter Emil van den Berg!
>>>>>>> Answered <<<<<<<
1 Reply
1 Follower