{% load pagination %}

{% if items.paginator.num_pages > 1 %}
    <div class="center">
        <div class="pagination" style="justify-content: center">
            {% if items.has_previous %}
                <a href="?page={{ items.previous_page_number }}&{{ request.META.QUERY_STRING|remove_param:"page" }}#results"
                   style="margin: 0 10px"
                   title="Previous Page"
                   data-ga-event-category="Pagination Click"
                   data-ga-event-label="{{ page.title }}"
                   data-ga-value="{{ items.previous_page_number }}"
                >
                    <span>&laquo;</span>
                </a>
            {% endif %}
            {% for page_num in items.paginator.page_range %}
                {% if page_num == items.number %}
                    <a href="?page={{ page_num }}&{{ request.META.QUERY_STRING|remove_param:"page" }}#results"
                       style="margin: 0 10px"
                       class="active"
                       data-ga-event-category="Pagination Click"
                       data-ga-event-label="{{ page.title }}"
                       data-ga-value="{{ page_num }}"
                    >

                        {{ page_num }}
                    </a>
                {% elif page_num > items.number|add:'-3' and page_num < items.number|add:'3' %}
                    <a href="?page={{ page_num }}&{{ request.META.QUERY_STRING|remove_param:"page" }}#results"
                       style="margin: 0 10px"
                       data-ga-event-category="Pagination Click"
                       data-ga-event-label="{{ page.title }}"
                       data-ga-value="{{ page_num }}"
                    >
                        {{ page_num }}
                    </a>
                {% endif %}

            {% endfor %}

            {% if items.has_next %}
                <a href="?page={{ items.next_page_number }}&{{ request.META.QUERY_STRING|remove_param:"page" }}#results"
                   style="margin: 0 10px"
                   title="Next Page"
                   data-ga-event-category="Pagination Click"
                   data-ga-event-label="{{ page.title }}"
                   data-ga-value="{{ items.next_page_number }}"
                >
                    <span>&raquo;</span>
                </a>
            {% endif %}
        </div>
    </div>
{% endif %}