{# Template : Search #}

{% extends ('layouts/' ~ page_meta.layout) %}

{% block content %}

    {% include 'includes/elements/title_wrap.twig' %}

    {% include 'navigation/breadcrumbs.twig' %}

    <div class="contentPageWrap searchWrap">

        <div class="contentWrap">
            <form action="/search" method="get">
                <div class="row">
                    <div class="inputWrap">
                        <input
                            placeholder="Search query here..."
                            type="text"
                            name="search_filter"
                            id="searchFilter"
                            class="text"
                            value="{{ search_term }}"
                        />
                    </div>
                </div>
                <div class="row">
                    <div class="inputWrap">
                        <input type="submit" value="Search"/>
                    </div>
                </div>
            </form>

            <ul class="searchList">
                {% for search_result in search_results %}

                    <li>
                        {% if search_result.pagedata['Image'][0]['value'] is not empty %}
                            <div class="imageWrap">
                                <a href="{{ search_result.url }}" title="{{ search_result.title }}">
                                    <picture>
                                        <img srcset="/{{ image_folders['cms_images']['small']['path'] }}/{{ search_result.pagedata['Image'][0]['value'] }}"
                                             alt='{{ search_result.pagedata['Image'][0]['alt'] }}' />
                                    </picture>
                                </a>
                            </div>
                        {% endif %}

                        <div class="infoWrap">

                            <h2>
                                <a href="{{ search_result.url }}" title="{{ search_result.title }}">{{ search_result.title }}</a>
                            </h2>

                            <div class="desc">
                                {% if search_result.pagedata['Content Summary'][0]['value'] is not empty %}
                                    {{ search_result.pagedata['Content Summary'][0]['value']|truncate(200, true, "...")|raw }}
                                {% else %}
                                    {{ search_result.pagedata['Content'][0]['value']|striptags|truncate(200, true, "...")|raw }}
                                {% endif %}
                            </div>

                            <a class="readMore" href="{{ search_result.url }}" title="{{ search_result.title }}">Read More</a>

                        </div>
                    </li>
                {% endfor %}
            </ul>

            <div class="searchPagination">
                <div class="paginumberorder">
                    {{ search_pagination['html']['full']|raw }}
                </div> <!-- .paginumberorder -->
            </div> <!-- .searchPagination -->

        </div> <!-- .contentContainer -->
    </div> <!-- .contentPageWrap -->

{% endblock %}
