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() %}
<li>{{ item.title }}</li>
{% endfor %}
The entry table format is as follows:
{% set field = craft.app.fields.getFieldByHandle('budgetTable') %}
<table id="apaf" class="table table-striped table-bordered" style="width:100%">
<thead >
<tr>
{% for column in field.settings.columns %}
<th scope="col" style="font-weight: bold;">{{ column.heading }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in entry.budgetTable %}
<tr>
<th scope="row" style="font-weight: bold;">{{ row.widgetTitle }}</th>
</tr>
{% endfor %}
</tbody>
</table>
budgetTable
is the name of the Table field. Does it only have 1 column with a handle ofwidgetTitle
? – Brad Bell May 18 '18 at 21:07