{# styles/infozone/template/forumlist_body.html #}
{% set iz_skip_cat = false %}
{% set iz_open_cat = false %}

{% for forumrow in forumrow %}

    {# --- CATEGORY ROWS --------------------------------------------------- #}
    {% if forumrow.S_IS_CAT or forumrow.S_FIRST_ROW or forumrow.S_NO_CAT %}

        {# Close the previous category/table if it was opened #}
        {% if iz_open_cat %}
                </tbody>
            </table>
            </div>
        </section>
        {% EVENT forumlist_body_category_footer %}
            {% set iz_open_cat = false %}
        {% endif %}

        {# Never skip categories; we may just relabel the legacy default category #}
        {% set iz_skip_cat = false %}

        {# Open the category/table if we are not skipping #}
        {% if not iz_skip_cat %}
            {% EVENT forumlist_body_category_header_before %}
            <section class="iz-forumcat">
                <header class="iz-forumcat__header">
                    <h2 class="iz-forumcat__title iz-center">
                        {% if forumrow.S_IS_CAT %}
                            {% if forumrow.FORUM_NAME|lower == 'your first category' %}
                                <a class="iz-link" href="{{ forumrow.U_VIEWFORUM }}">Recent discussions</a>
                            {% else %}
                                <a class="iz-link" href="{{ forumrow.U_VIEWFORUM }}">{{ forumrow.FORUM_NAME }}</a>
                            {% endif %}
                        {% elseif forumrow.S_IS_LINK %}
                            {{ L_LINKS }}
                        {% else %}
                            {{ L_FORUM }}
                        {% endif %}
                    </h2>
                </header>

                <div class="iz-forumcat__body">
                    <table class="iz-table iz-table--forumlist">
                        <thead>
                            {% EVENT forumlist_body_category_header_row_prepend %}
                            <tr>
                                <th scope="col" class="iz-table__col-title iz-center">{{ L_TITLE }}</th>
                            </tr>
                            {% EVENT forumlist_body_category_header_row_append %}
                        </thead>
                        <tbody>
            {% EVENT forumlist_body_category_header_after %}
            {% set iz_open_cat = true %}
        {% endif %}
    {% endif %}

    {# --- FORUM ROWS ------------------------------------------------------ #}
    {% if not forumrow.S_IS_CAT and not iz_skip_cat %}
        {% EVENT forumlist_body_forum_row_before %}
        <tr id="forum-{{ forumrow.FORUM_ID }}" class="iz-forumrow">
            {% EVENT forumlist_body_forum_row_prepend %}
            <td class="iz-forumrow__main" title="{{ forumrow.FORUM_FOLDER_IMG_ALT }}">
                <div class="iz-forumrow__onlytitle">
                    <a href="{{ forumrow.U_VIEWFORUM }}" class="forumtitle iz-forumrow__title iz-center">{{ forumrow.FORUM_NAME }}</a>
                </div>
            </td>
            {% EVENT forumlist_body_forum_row_append %}
        </tr>
        {% EVENT forumlist_body_forum_row_after %}
    {% endif %}

{% endfor %}

{# Close the final opened category/table if needed #}
{% if iz_open_cat %}
        </tbody>
    </table>
    </div>
</section>
{% EVENT forumlist_body_category_footer %}
{% endif %}
