<p>Every entry in a section has a table.  The table depicts sales over 7 years.</p>

<p><strong>I want to create an <code>index page</code> that lists the title of each entry and the sales for each entry in the section.</strong>  </p>

<p>I know how to loop through the table fields to template the table for each entry. </p>

<p>I know how to loop through the titles of each entry to create an index page.</p>

<p><strong>But, how do I create an index page that loops through the table data for each entry?</strong></p>

<p>Simple index loop: </p>

<pre><code>{% for item in craft.entries.section('widgets').all() %}
    &lt;li&gt;{{ item.title }}&lt;/li&gt;        
{% endfor %}
</code></pre>

<p>The entry table format is as follows:</p>

<pre><code>{% set field = craft.app.fields.getFieldByHandle('budgetTable') %}   

        &lt;table id="apaf" class="table table-striped table-bordered" style="width:100%"&gt;
            &lt;thead &gt;
                &lt;tr&gt;
                    {% for column in field.settings.columns %}
                    &lt;th scope="col" style="font-weight: bold;"&gt;{{ column.heading }}&lt;/th&gt;
                    {% endfor %}
                &lt;/tr&gt;    
            &lt;/thead&gt;     

            &lt;tbody&gt;
                {% for row in entry.budgetTable %}
                &lt;tr&gt;    

                    &lt;th scope="row" style="font-weight: bold;"&gt;{{ row.widgetTitle }}&lt;/th&gt;

                &lt;/tr&gt;          
                {% endfor %}

            &lt;/tbody&gt;          
        &lt;/table&gt;
</code></pre>

CC BY-SA 4.0
2018-05-18T21:07:40.850Z
Not sure I'm following 100%.  `budgetTable` is the name of the Table field. Does it only have 1 column with a handle of `widgetTitle`?
Brad Bell
CC BY-SA 4.0
2018-05-20T17:48:50.210Z
@Brad Bell.  I only depict 1 column handle.  There are actually 10.
Hellyar
<templating><forloop><table-field><table>
How do I create an index page that loop through the table fields of its entries?
# How do I create an index page that loop through the table fields of its entries?

(Asked by: username_0 on 2018-05-18)

Every entry in a section has a table.  The table depicts sales over 7 years.
I want to create an index page that lists the title of each entry and the sales for each entry in the section. 
I know how to loop through the table fields to template the table for each entry. 
I know how to loop through the titles of each entry to create an index page.
But, how do I create an index page that loops through the table data for each entry?
Simple index loop: 
{% for item in craft.entries.section('widgets').all() %}
    {{ item.title }}        
{% endfor %}

The entry table format is as follows:
{% set field = craft.app.fields.getFieldByHandle('budgetTable') %}   

        
            
                
                    {% for column in field.settings.columns %}
                    {{ column.heading }}
                    {% endfor %}
                    
                 

            
                {% for row in entry.budgetTable %}
                    

                    {{ row.widgetTitle }}

                          
                {% endfor %}

**Tags:** templating, forloop, table-field, table

> **Comments:**
> **username_1**: Not sure I'm following 100%.  `budgetTable` is the name of the Table field. Does it only have 1 column with a handle of `widgetTitle`?  
> **username_0**: @username_1.  I only depict 1 column handle.  There are actually 10.  

---

## 0 answers

