Pageworks / papertrain

Papertrain: a Craft CMS 3 framework
http://download.papertrain.io
MIT License
5 stars 2 forks source link

Add Table Block #119

Closed codewithkyle closed 5 years ago

codewithkyle commented 5 years ago
{% set rowIndex = 0 %}
{% set maxIndex = 0 %}
{% for column in block.tableContent %}
    {% if column.columnRows|length > maxIndex %}
        {% set maxIndex = column.columnRows|length %}
    {% endif %}
{% endfor %}

{% if block.tableContent|length %}
    <div class="b-table o-wrapper u-1/1 {{ block.paddingType }}{{ block.paddingSize }}">
        <table class="o-table">
            <tbody>
                <tr>
                    {% for column in block.tableContent %}
                        <td>{{ column.columnHeading }}</td>
                    {% endfor %}
                    <td>&nbsp;</td>
                </tr>
                {% for i in 1..maxIndex %}
                    <tr>
                        {% for column in block.tableContent %}
                            {% for row in column.columnRows %}
                                {% if loop.index0 == rowIndex %}
                                    <td>{{ row.rows }}</td>
                                {% endif %}
                            {% endfor %}
                        {% endfor %}
                        {% set rowIndex = rowIndex + 1 %}
                        <td>&nbsp;</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endif %}

Also update the <td> last of type width the be 100% and remove the padding.