AJenbo/agcms

View on GitHub
application/theme/default/partial-table.html

Summary

Maintainability
Test Coverage
{% apply spaceless %}
<table class="tabel">
    {% if table.title %}<caption>{{table.title}}</caption>{% endif %}
    <thead>
        <tr>
            {% for column in table.columns %}
            <td>
                <a href="" onclick="return getTable({{category.id}}, {{table.id}}, {{loop.index0}})">
                    {{column.title}}
                </a>
            </td>
            {% endfor%}
            {% if table.hasPrices %}<td></td>{% endif %}
        </tr>
    </thead>
    <tbody>
        {% for row in table.rows(orderBy) %}
        {% set forSale = false %}
        <tr{% if loop.index is even %} class="altrow"{% endif %}>
            {% for column in table.columns %}
            {% if (column.isCheckoutPrice and row[loop.index0] > 0) %}
                {% set forSale = true %}
            {% endif %}
            <td{% if not column.isText %} style="text-align:right"{% endif %}{% if column.isPrice %} class="{% if column.isDiscountPrice %}Ny{% elseif column.isPreviousPrice %}X{% endif %}Pris"{% endif %}>
                {% if table.hasLinks and row.page %}<a href="{{row.page.canonicalLink(category)}}">{% endif %}
                    {% if not column.isPrice %}
                        {{row[loop.index0]}}
                    {% else %}
                        {% if row[loop.index0] > 0 %}
                            {{row[loop.index0]|money(true, 0)}}{{'.00'|trans}}
                        {% elseif row[loop.index0] < 0 %}
                            {{'Sold-out'|trans}}
                        {% endif %}
                    {% endif %}
                {% if table.hasLinks %}</a>{% endif %}
            </td>
            {% endfor %}
            {% if table.hasPrices %}
            <td class="addtocart">
                {% if forSale %}
                <a href="" onclick="shoppingCart.addItem('line',{{row.id}});return false">
                    <img src="/theme/default/images/cart_add.png" title="{{'Add to shopping cart'|trans}}" alt="+" />
                </a>
                {% endif %}
            </td>
            {% endif %}
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endapply %}