{% extends "base.html" %}
{% load static wagtailcore_tags wagtailsearchpromotions_tags %}

{% block body_class %}template-searchresults{% endblock %}

{% block title %}Search{% endblock %}

{% block content %}
<section id="search-page">
  <div class="container">
    <center>
      <form action="{% url 'search' %}" method="get">
        <input type="text" name="query"{% if search_query %} value="{{ search_query }}"{% endif %}>
        <button type="submit" title="Search">
          <span class="glyphicon glyphicon-search" aria-hidden="false"></span>
        </button>
      </form>
    </center>

    {% get_search_promotions search_query as search_picks %}
    {% if search_picks %}
         <ul>
            {% for pick in search_picks %}
                <li>
                    <h2><a href="{{ pick.page.url }}">{{ pick.page }}</a></h2>
                    <p>{{ pick.description }}</p>
                </li>
             {% endfor %}
         </ul>
    {% endif %}

    {% if search_results %}
        <ul>
            {% for result in search_results %}
                <li>
                    <h4><a href="{% pageurl result %}">{{ result }}</a></h4>
                    {% if result.search_description %}
                        {{ result.search_description|safe }}
                    {% endif %}
                </li>
            {% endfor %}
        </ul>

        {% if search_results.has_previous %}
            <a href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results.previous_page_number }}">
              {{ search_results.previous_page_number }}
              &lt;&lt;</a>
        {% endif %}

        {% if search_results.has_next %}
            <a href="{% url 'search' %}?query={{ search_query|urlencode }}&amp;page={{ search_results.next_page_number }}">
              &gt;&gt;
              {{ search_results.next_page_number }}</a>
        {% endif %}
    {% elif search_query %}
      <center><h5><i>Leider keine Ergebnisse gefunden<br><br>Désolé, aucun résultat n'a été trouvé</i></h5></center>
    {% endif %}

</div>
</section>
{% endblock %}
