{% extends "@templates/"~template~"/view/base.html.twig" %}

{% block javascript %}
    {{ parent() }}
    <script src="{{ asset('media/Public/js/search.js') }}"></script>
{% endblock %}

{% block content %}
<div class="grid-container">
    <div class="grid-x searchResult">
        <div class="cell">
            <h1>Wyniki wyszukiwania</h1>
            <p>dla frazy: {{ search }}</p>
            {% set count = pages|length + news|length + blog|length %}
            {% if count == 0 %}
                Brak wyników dla wyszukiwanej frazy
            {% endif %}
            {% if pages|length > 0 %}
                <hr>
                <h5>Strony / Artykuły:</h5>
                {% for page in pages %}
                    {% set metaData = getMetaArrayValues(page) %}
                    <div class="grid-x searchResultRow">
                        <div class="cell">
                            <h6><a href="{{ path('wi_front_page_index', {'id': page.id, 'slug': slugify(page.title)}) }}" title="{{ metaData.title }}">{{ metaData.title }}</a></h6>
                            <small><a href="{{ metaData.canonical }}" title="{{ metaData.title }}">{{ metaData.canonical }}</a></small>
                            <p>{{ metaData.description|raw }}</p>
                        </div>
                    </div>
                {% endfor %}
                <div class="grid-x">
                    <div class="cell text-center">
                        {{ knp_pagination_render(pages, '@KnpPaginator/Pagination/sliding.html.twig') }}
                    </div>
                </div>
            {% endif %}
            {% if news|length > 0 %}
                <hr>
                <h5>Aktualności:</h5>
                {% for item in news %}
                    {% set metaData = getMetaArrayValues(item) %}
                    <div class="grid-x searchResultRow">
                        <div class="cell">
                            <h6><a href="{{ path('wi_front_news_show', {'id': item.id, 'slug': slugify(item.title)}) }}" title="{{ metaData.title }}">{{ metaData.title }}</a></h6>
                            <small><a href="{{ metaData.canonical }}" title="{{ metaData.title }}">{{ metaData.canonical }}</a></small>
                            <p>{{ metaData.description|raw }}</p>
                        </div>
                    </div>
                {% endfor %}
                <div class="grid-x">
                    <div class="cell text-center">
                        {{ knp_pagination_render(news, '@KnpPaginator/Pagination/sliding.html.twig') }}
                    </div>
                </div>
            {% endif %}
            {% if blog|length > 0 %}
                <hr>
                <h5>Posty:</h5>
                {% for item in blog %}
                    {% set metaData = getMetaArrayValues(item) %}
                    <div class="grid-x searchResultRow">
                        <div class="cell">
                            <h6><a href="{{ path('wi_front_news_show', {'id': item.id, 'slug': slugify(item.title)}) }}" title="{{ metaData.title }}">{{ metaData.title }}</a></h6>
                            <small><a href="{{ metaData.canonical }}" title="{{ metaData.title }}">{{ metaData.canonical }}</a></small>
                            <p>{{ metaData.description|raw }}</p>
                        </div>
                    </div>
                {% endfor %}
                <div class="grid-x">
                    <div class="cell text-center">
                        {{ knp_pagination_render(blog, '@KnpPaginator/Pagination/sliding.html.twig') }}
                    </div>
                </div>
            {% endif %}
        </div>
    </div>
</div>

{% endblock %}
