{% extends 'iconolab_base.html' %}

{% load thumbnail %}
{% load iconolab_tags %} 

{% block content %}

    <h2>Recherche</h2>

    <form method="get" action=".">
        <table>
            
            <tr>
                <td> {{ form.as_p }} </td> 

                <td>
                    <input style="margin:0px" type="submit" value="Rechercher">
                </td>
            </tr>
        </table>

            <h3><strong>{{ page_obj.paginator.count }}</strong> image(s)</h3>
            
            {% for result in page_obj.object_list %}

            {% thumbnail result.object.media "400x400" crop=False as im %}
            <div class="annotation-item result" style="position:relative;">
                <a href="{% url 'item_detail' result.object.collection result.object.item.item_guid %}">
                    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
                </a>
            </div>
            {% endthumbnail %}

                <p>
                    <a href="{% url 'item_detail' result.object.collection result.object.item.item_guid %}">{{ result.object.title }}</a>
                    <span>collection {{result.object.collection}}</span>
                </p>
            {% empty %}
                <p>Aucune image n'a été trouvée.</p>
            {% endfor %}

            {% if page_obj.has_previous or page_obj.has_next %}
                <div>
                    {% if page_obj.has_previous %}<a href="?q={{ query }}&amp;page={{ page_obj.previous_page_number }}">{% endif %}&laquo; Previous{% if page_obj.has_previous %}</a>{% endif %}
                    |
                    {% if page_obj.has_next %}<a href="?q={{ query }}&amp;page={{ page_obj.next_page_number }}">{% endif %}Next &raquo;{% if page_obj.has_next %}</a>{% endif %}
                </div>
            {% endif %}
    </form>
{% endblock %}