/
search.twig
90 lines (77 loc) · 3.7 KB
/
search.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{% extends 'partials/_master.twig' %}
{% block main %}
<section class="section section-listing">
<div class="container">
{# This template is used for search results. If 'search' is defined,
we display an appropriate title. The 'records' array contains all of the
records matching the current query. If there are no results, the
code in the 'else' part of the for-loop is used. #}
<h1 class="title is-size-2 is-size-4-mobile">
{% if search is not empty %}
{{ __('general.phrase.search-results-for-variable', { '%search%': search }) }}
{% else %}
{{ __('general.phrase.search') }}
{% endif %}
</h1>
{# Perhaps we post a small teaser, stored in the 'block' named 'Search teaser' #}
{% setcontent block = "block/search-teaser" %}
{# check if we have 'content'. If so, we know we have have a teaser to display. #}
{% if block.content is defined %}
<div class="content">
{{ block.content }}
</div>
{% endif %}
<form class="field has-addons" method="get" action="{{ path('search') }}" enctype="text/plain">
<label class="label is-hidden" for="search-form">Search</label>
<div class="control">
<input class="input" type="search" value="{% if search is defined %}{{ search|escape }}{% endif %}" placeholder="{{ __('general.phrase.search-ellipsis') }}" name="search" id="search-form">
</div>
<div class="control">
<button class="button is-primary" type="submit">{{ __('general.phrase.search') }}</button>
</div>
</form>
</div>
</section>
<section class="section section-listing">
<div class="container">
{% for record in records %}
<article role="article" class="media columns">
<div class="media-content column is-7">
<div class="content">
<h2 class="title"><a href="{{ record.link }}">{{ record.title }}</a></h2>
<p class="meta is-hidden-touch">
{% if record.editlink() %}
<span class="edit-link"><a href="{{ record.editlink() }}"><strong>Edit</strong></a></span> •
{% endif %}
<a href="{{ record.link() }}">{{ __('general.phrase.permalink') }}</a> •
{{ __('general.phrase.written-by-on', {
'%name%': record.user.displayname|default(__('Unknown')),
'%date%': record.datepublish|localedatetime("%A %B %e, %Y")
}) }}
</p>
{# display something introduction-like.. #}
<p>{{ record.excerpt(300, false, search|default('')) }}</p>
</div>
</div>
{% if record.image is not empty %}
<div class="media-right column">
<figure class="image">
<img src="{{ record.image|image(480, 320, "r") }}" alt="{{ record.values.image.alt|default() }}" />
</figure>
</div>
{% endif %}
</article>
{% else %}
<article role="article" class="media">
<div class="media-content">
<div class="content">
<p>{{ __('general.phrase.no-result-for-search-term', { '%SEARCHTERM%': search|escape }) }}</p>
</div>
</div>
</article>
{% endfor %}
{# If there are more records than will fit on one page, the pager is shown. #}
{{ pager(template = 'partials/_sub_pager.twig') }}
</div>
</section>
{% endblock main %}