{% extends "oscar/catalogue/browse.html" %}

{% load currency_filters %}
{% load thumbnail %}
{% load product_tags %}
{% load wagtailcore_tags wagtailsearchpromotions_tags %}
{% load i18n %}
{% load static ocyanjson %}

{% block banner_classes %}search-block{% endblock %}

{% block categories %}{% endblock %}
{% block banner_header %}
<p class="text-white mb-0">{% trans "Results for" %}</p>
<h3 class="text-white">"{{ search_form.q.value }}"</h3>
{% endblock %}

{% block product_list %}
{% ocyanjson "themes" "product_column_classes" as product_column_classes %}

<form method="get">
    {# Render other search params as hidden inputs #}
    {% for value in search_form.selected_facets %}
    <input type="hidden" name="selected_facets" value="{{ value }}" >
    {% endfor %}
    <input type="hidden" name="q" value="{{ search_form.q.value }}" >
    {% get_search_promotions search_form.q.value as search_promotions %}

    {% if search_promotions %}
    <ul class="list-group mb-5" id="search_promotions">
        {% for search_promotion in search_promotions %}
        <li>
            <a href="{% pageurl search_promotion.page %}" class="text-dark">
                <span class="h4 mb-0 text-primary">{{ search_promotion.page.title }}</span>
                <small class="text-primary"><div class="search_badge border-primary">Voorgestelde pagina</div> {% if search_promotion.page.url %}<span class="promotion_url">{{ search_promotion.page.url }}</span>{% endif %}</small>
                <small class="small-lead">{{ search_promotion.description|truncatechars:250 }}</small>
            </a>
        </li>
        {% endfor %}
    </ul>
    {% endif %}
</form>

{% block product_list_section %}
{% if page.object_list %}
<section class="products-wrapper mt-5">
    {% block category_top %}{% endblock %}
    <div class="products row">
        {% for product in page.object_list %}
        <div class="{% if product_column_classes %}{{product_column_classes}}{% else %}col-6 col-lg-4 col-xl-4{% endif %}">
            {% if forloop.counter > 2 %}
            {% render_product product %}
            {% else %}
            {% with notlazy=True %}{% render_product product %}{% endwith %}
            {% endif %}
        </div>
        {% endfor %}
    </div>
    {% block category_bottom %}{% endblock %}
    {% include "oscar/partials/pagination.html" with page_obj=page %}
</section>
{% else %}
<div class="text-center">
<h2 class="h4">{% trans "No products found." %}</h2>
{% if suggestion %}
{% url 'search:search' as search_url %}
{% blocktrans %}Did you mean <a href="{{ search_url }}?q={{ suggestion }}">"{{ suggestion }}"</a>?{% endblocktrans %}
{% endif %}
</div>
{% endif %}
{% endblock product_list_section %}

{% endblock %}
