{% extends "@templates/"~template~"/view/base.html.twig" %}

{% block meta %}{{ getMeta(category) }}{% endblock %}

{% block javascript %}
<script src="{{ asset('media/Public/vendor/lightbox/dist/js/lightbox.min.js') }}"></script>
{{- parent() -}}
{% endblock %}

{%- macro categoriesMenu(categories) -%}
    <ul>
        {%- for category in categories -%}
            <li><a href="{{ url('front_ecommerce_product_by_category', { 'id': category.id, 'slug': slugify(category.title) }) }}">{{ category.title }}</a>
                {%- if category.children.count > 0 -%}
                    {%- import _self as macro -%}
                    {{- macro.categoriesMenu(category.children) -}}
                {%- endif -%}
            </li>
        {%- endfor -%}
    </ul>
{%- endmacro -%}
{% import _self as macro %}

{% block content %}
    <div class="grid-container">
        <div class="grid-x grid-margin-x">
            <div class="large-3 cell">
                <h4>Kategorie</h4>
                {{ macro.categoriesMenu(categories) }}
                <hr style="margin:0;">
                <a href="{{ url('front_ecommerce_product_index') }}"><small>wszystkie produkty</small></a>
            </div>
            <div class="large-9 cell">
                {%- if category is not null -%}
                    <h4>{{ category.title }}</h4>
                    <div>{{ category.content|raw }}</div>
                {%- endif -%}

                <h4>Produkty</h4>
                <div class="grid-x grid-margin-x">
                    {%- for product in products -%}
                        <div class="large-4 cell">
                            <img src="{{ absolute_url(asset(product.getImage('thumbnailS'))) }}" alt="{{ product.title }}">
                            <p>{{ product.title }}</p>
                            <p>
                                {%- for category in product.categories -%}
                                    <a href="{{ url('front_ecommerce_product_by_category', { 'id': category.id, 'slug': slugify(category.title) }) }}" class="label">{{ category.title }}</a>
                                {%- endfor -%}
                            </p>
                            <p>{{ product.shortcut }}</p>
                            <p><a href="{{ url('front_ecommerce_product_show', { 'id': product.id, 'slug': slugify(product.title) }) }}">zobacz &rarr;</a></p>
                        </div>
                    {%- endfor -%}
                </div>
                {{ knp_pagination_render(products, '@KnpPaginator/Pagination/sliding.html.twig') }}
            </div>
        </div>
    </div>
{% endblock %}
