search.html 2.42 KB
Newer Older
fred's avatar
fred committed
1
{% extends 'base.html' %}
2 3 4 5 6 7 8 9 10 11

{% block content %}
    <h2>Recherche</h2>

    <form method="get" action=".">
        <table>
            {{ form.as_table }}
            <tr>
                <td>&nbsp;</td>
                <td>
12
                  <button>Rechercher</button>
13 14 15 16 17
                </td>
            </tr>
        </table>

        {% if query %}
fred's avatar
fred committed
18
    <!-- Begin faceting. -->
fred's avatar
fred committed
19

fred's avatar
fred committed
20 21
<p>
    {% if facets.fields.categories %}
22 23
    Catégories :
      {# Provide only the top 5 categories #}
fred's avatar
fred committed
24
        {% for category in facets.fields.categories|slice:":5" %}
fred's avatar
fred committed
25 26 27
          {% if category.0 in selected_categories %}
            <strong>{{ category.0 }}</strong> ({{ category.1 }})
          {% else %}
fred's avatar
fred committed
28
            <span><a href="{{ request.get_full_path }}&amp;selected_facets=categories_exact:{{ category.0|urlencode }}">{{ category.0 }}</a> ({{ category.1 }})</span>
fred's avatar
fred committed
29
          {% endif %}
fred's avatar
fred committed
30 31 32 33 34 35
        {% endfor %}
    {% else %}
        No categories facets.
    {% endif %}
</p>

36 37 38 39 40
<p>
    {% if facets.fields.tags %}
    Tags :
      {# Provide only the top 5 tags #}
        {% for tag in facets.fields.tags|slice:":5" %}
fred's avatar
fred committed
41 42 43
          {% if tag.0 in selected_tags %}
            <strong>{{ tag.0 }}</strong> ({{ tag.1 }})
          {% else %}
44
            <span><a href="{{ request.get_full_path }}&amp;selected_facets=tags_exact:{{ tag.0|urlencode }}">{{ tag.0 }}</a> ({{ tag.1 }})</span>
fred's avatar
fred committed
45
          {% endif %}
46 47 48 49 50 51 52
        {% endfor %}
    {% else %}
        No tags facets.
    {% endif %}
</p>


fred's avatar
fred committed
53 54
    <!-- End faceting -->

55 56
            <h3>Résultats</h3>

fred's avatar
fred committed
57

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
            {% for result in page.object_list %}
                <p>
                    <a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
                </p>
            {% empty %}
                <p>Aucun résultat trouvé.</p>
            {% endfor %}

            {% if page.has_previous or page.has_next %}
                <div>
                    {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Précédente{% if page.has_previous %}</a>{% endif %}
                    |
                    {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Suvante &raquo;{% if page.has_next %}</a>{% endif %}
                </div>
            {% endif %}
        {% else %}
            {# Show some example queries to run, maybe query syntax, something else? #}
        {% endif %}
    </form>
{% endblock %}