Viewing 1 replies (of 1 total)
  • Plugin Author Johann Heyne

    (@jonua)

    Hi,

    I′m not into this template engine, but in some way it should work like…

    <?php
    
        echo $twig->render( 'template.html', array( 'table' => get_field( 'my_table_field' ) ) );
    

    template.html…

    {% if table|length > 0 %}
    
        <table>
        
            % if table.header|length > 0 %}
                <thead>
                    <tr>
                        {% for header in table.header %}
                            <th>{{ header.c }}</th>
                        {% endfor %}
                    </tr>
                </thead>
            {% endif %}
    
            % if table.body|length > 0 %}
                <tbody>
                {% for row in table.body %}
                    <tr>
                        {% for cell in row %}
                            <td>{{ cell.c }}</td>
                        {% endfor %}
                    </tr>
                {% endfor %}
                </tbody>
            {% endif %}
        
        </table>
        
    {% endif %}
    • This reply was modified 7 years, 8 months ago by Johann Heyne.
    • This reply was modified 7 years, 8 months ago by Johann Heyne.
    • This reply was modified 7 years, 8 months ago by Johann Heyne.
Viewing 1 replies (of 1 total)
  • The topic ‘Table field in Twig file’ is closed to new replies.