Answers.Body: <p>Would this work?</p>
  
  <pre><code>{% set teams = craft.entries.section('team').relatedTo(studios) %}
  
  &lt;h2&gt;All teams in {{entry.title}}&lt;/h2&gt;
  {% for team in teams %}
      &lt;h3&gt;{{team.title}}&lt;/h3&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T09:41:32.700Z
Answers.Text: Thank Jamie it does work!
  Seems like I underestimated craft :D
Answers.UserDisplayName: Marco Schuler
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T09:26:30.357Z
Answers.LastActivityDate: 2016-04-07T09:26:30.357Z
Answers.UserDisplayName: Jamie Pittock
Body: <p>Let’s say i have a location channel, a studio and a team channel. A location contains one or several studios and a studio contains one or several teams.
  I can display all the teams in a location by looping through all the studios related to the location and then through all the teams related to the studio.</p>
  
  <p>Is it somehow possible to do that in one loop?  To only loop through all the teams related to the location ( which aren’t related directly to each other)?</p>
  
  <p>location/_entry.html :</p>
  
  <pre><code>{% set studios = craft.entries.section('studio').relatedTo(entry) %}
  
  {% block content %}
    &lt;article&gt;
      &lt;h2&gt;Studios in {{entry.title}}&lt;/h2&gt;
      {% for studio in studios %}
        &lt;h3&gt;{{studio.title}}&lt;/h3&gt;
      {% endfor %}
  
      &lt;h2&gt;All teams in {{entry.title}}&lt;/h2&gt;
        {% for studio in studios %}
        {% for team in craft.entries.section('team').relatedTo(studio) %}
          &lt;h3&gt;{{team.title}}&lt;/h3&gt;
        {% endfor %}
      {% endfor %}
    &lt;/article&gt;
  {% endblock %}
  </code></pre>
  
Tags: <templating><relations>
Title: Prettiest way to loop through nested relations?
ThreadText: # Prettiest way to loop through nested relations?
  
  (Asked by: username_0 on 2016-04-07)
  
  Let’s say i have a location channel, a studio and a team channel. A location contains one or several studios and a studio contains one or several teams.
  I can display all the teams in a location by looping through all the studios related to the location and then through all the teams related to the studio.
  
  Is it somehow possible to do that in one loop? To only loop through all the teams related to the location ( which aren’t related directly to each other)?
  
  location/\_entry.html :
  
  ```
  {% set studios = craft.entries.section('studio').relatedTo(entry) %}
  
  {% block content %}
    <article>
      <h2>Studios in {{entry.title}}</h2>
      {% for studio in studios %}
        <h3>{{studio.title}}</h3>
      {% endfor %}
  
      <h2>All teams in {{entry.title}}</h2>
        {% for studio in studios %}
        {% for team in craft.entries.section('team').relatedTo(studio) %}
          <h3>{{team.title}}</h3>
        {% endfor %}
      {% endfor %}
    </article>
  {% endblock %}
  
  ```
  
  **Tags:** templating, relations
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-07. Score: 4 | Accepted answer
  
  Would this work?
  
  ```
  {% set teams = craft.entries.section('team').relatedTo(studios) %}
  
  <h2>All teams in {{entry.title}}</h2>
  {% for team in teams %}
      <h3>{{team.title}}</h3>
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thank username_1 it does work! Seems like I underestimated craft :D  
  
  ---
  
  