Body: <p>Each of my entries has a table with budget projections.</p>
  
  <p>I loop through related entries.   <strong>But, how can I loop through and bring in the related table?</strong></p>
  
  <p>This is my table for the entry:</p>
  
  <pre><code> {% set field = craft.app.fields.getFieldByHandle('budgetProjections') %}
      &lt;table width="100%"&gt;
          &lt;tr&gt;
  
              {% for column in field.settings.columns %}
                  &lt;th&gt;{{ column.heading }}&lt;/th&gt;
              {% endfor %}
  
          &lt;/tr&gt;
          {% for row in entry.budgetProjections %}
          &lt;tr&gt;    
              &lt;td&gt;{{ row.col1 }}&lt;/td&gt;
              &lt;td&gt;{{ row.col2 }}&lt;/td&gt;
              &lt;td&gt;{{ row.col3 }}&lt;/td&gt;
              &lt;td&gt;{{ row.col4 | number_format (0,'.',',')}}&lt;/td&gt;
              &lt;td&gt;{{ row.col5 | number_format (0,'.',',')}}&lt;/td&gt;
              &lt;td&gt;{{ row.col6 | number_format (0,'.',',')}}&lt;/td&gt;
              &lt;td&gt;{{ row.col7 | number_format (0,'.',',')}}&lt;/td&gt;
              &lt;td&gt;{{ row.col8 | number_format (0,'.',',')}}&lt;/td&gt;
              &lt;td&gt;{{ row.col9 | number_format (0,'.',',')}}&lt;/td&gt;
              &lt;td&gt;{{ row.col10 | number_format (0,'.',',') }}&lt;/td&gt;
          &lt;/tr&gt;          
          {% endfor %}
      &lt;/table&gt;
  </code></pre>
  
  <p>This is my loop for related entries.  It creates a button and link for each related entry.  <strong>But now, I want to pull in the related table.  How do I do that?</strong></p>
  
  <pre><code>{% set related = entry.relatedBudgetItems.all() %}
      {% if related %}
  
      &lt;p&gt; {% for item in related %}
  
          &lt;a href="{{ item.getUrl() }}" class="button primary radius"&gt;&lt;i&gt;{{ item.title}} ({{ item.lineItem }})-  &lt;/i&gt;&lt;/a&gt;
          {% endfor %}
      &lt;/p&gt;   
      {% endif %}
  </code></pre>
  
  <p>Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-04T19:11:38.527Z
Comments.Text: Can't you do it the same way as above just with the `item` variable instead of the `entry`
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-04T19:26:55.007Z
Comments.Text: @RobinSchambach  Yep.  I forgot all about that `entry`.  Thanks.
Comments.UserDisplayName: Hellyar
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-04T19:41:11.550Z
Comments.Text: If your question is solved, would you mind answering it with your solution?
Comments.UserDisplayName: Robin Schambach
Tags: <templating><relatedto>
Title: How can I pull in a related table?
ThreadText: # How can I pull in a related table?
  
  (Asked by: username_0 on 2018-05-04)
  
  Each of my entries has a table with budget projections.
  
  I loop through related entries. **But, how can I loop through and bring in the related table?**
  
  This is my table for the entry:
  
  ```
   {% set field = craft.app.fields.getFieldByHandle('budgetProjections') %}
      <table width="100%">
          <tr>
  
              {% for column in field.settings.columns %}
                  <th>{{ column.heading }}</th>
              {% endfor %}
  
          </tr>
          {% for row in entry.budgetProjections %}
          <tr>    
              <td>{{ row.col1 }}</td>
              <td>{{ row.col2 }}</td>
              <td>{{ row.col3 }}</td>
              <td>{{ row.col4 | number_format (0,'.',',')}}</td>
              <td>{{ row.col5 | number_format (0,'.',',')}}</td>
              <td>{{ row.col6 | number_format (0,'.',',')}}</td>
              <td>{{ row.col7 | number_format (0,'.',',')}}</td>
              <td>{{ row.col8 | number_format (0,'.',',')}}</td>
              <td>{{ row.col9 | number_format (0,'.',',')}}</td>
              <td>{{ row.col10 | number_format (0,'.',',') }}</td>
          </tr>          
          {% endfor %}
      </table>
  
  ```
  
  This is my loop for related entries. It creates a button and link for each related entry. **But now, I want to pull in the related table. How do I do that?**
  
  ```
  {% set related = entry.relatedBudgetItems.all() %}
      {% if related %}
  
      <p> {% for item in related %}
  
          <a href="{{ item.getUrl() }}" class="button primary radius"><i>{{ item.title}} ({{ item.lineItem }})-  </i></a>
          {% endfor %}
      </p>   
      {% endif %}
  
  ```
  
  Thanks!
  
  **Tags:** templating, relatedto
  
  > **Comments:**
  > **username_1**: Can't you do it the same way as above just with the `item` variable instead of the `entry`  
  > **username_0**: @username_1  Yep.  I forgot all about that `entry`.  Thanks.  
  > **username_1**: If your question is solved, would you mind answering it with your solution?  
  
  ---
  
  ## 0 answers
  
  