/
tease-search.twig
162 lines (151 loc) · 7.45 KB
/
tease-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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{% set ga_page_type = post.post_type|capitalize %}
{% set post_link = post.link %}
{% if ( 'p4_action' == post.post_type ) %}
{% set is_action = true %}
{% set ga_page_type = 'Take Action' %}
{% elseif ( 'attachment' == post.post_type ) %}
{% set is_document = true %}
{% set ga_page_type = 'Document' %}
{% set post_link = fn('wp_get_attachment_url', post.id) %}
{% elseif ( 'campaign' == post.post_type ) %}
{% set is_campaign = true %}
{% elseif ( 'archive' == post.post_type ) %}
{% set is_archive = true %}
{% endif %}
{% if ( current_page == 1 and loop.index0 == 0 ) %}
<div class="search-results-load">
{% elseif ( first_of_the_page and loop.index0 is divisible by(5) ) %}
<div class="search-results-load row-hidden" style="display: none;">
{% endif %}
<li id="result-row-{{ post.ID }}" class="d-flex search-result-list-item">
<a
class="d-flex search-result-item-image"
href="{{ post_link }}"
data-ga-category="Search Results"
data-ga-action="Image"
data-ga-label="{{ ga_page_type }}">
<img
src="{{ post.thumbnail ?: dummy_thumbnail }}"
loading="lazy"
alt="{{ fn('esc_attr', post.thumbnail_alt|default( post.post_title ) )|raw }}" />
</a>
<div id="tease-{{ post.ID }}" class="search-result-item-body tease tease-{{ post.post_type }}">
<div class="search-result-item-flex-title">
<div>
{% if ( is_archive or is_campaign ) %}
<div class="search-results-alternative-label search-results-alternative-label-mobile">
{% if ( is_campaign ) %}
{{ __( 'Campaign', 'planet4-master-theme' ) }}
{% elseif ( is_archive ) %}
{{ __( 'Archive', 'planet4-master-theme' ) }}
{% endif %}
</div>
{% endif %}
{% if ( post.p4_page_types or post.tags ) %}
<div class="search-result-tags top-page-tags">
{% for page_type in post.p4_page_types %}
<a
class="search-result-item-head no-btn tag-item tag-item--main page-type"
href="{{ page_type.link }}"
data-ga-category="Search Results"
data-ga-action="Post Type Tag"
data-ga-label="{{ ga_page_type }}">
{{ page_type.name|e('wp_kses_post')|raw }}
</a>
{% endfor %}
{% if ( post.p4_page_types and post.tags ) %}
<span class="tag-wrap-bullet" aria-hidden="true">•</span>
{% endif %}
{% if (post.tags) %}
<div class="tag-wrap tags">
{% for tag in post.tags %}
<a
href="{{ tag.link }}"
class="search-result-item-tag tag-item tag"
data-ga-category="Search Results"
data-ga-action="Navigation Tag"
data-ga-label="{{ ga_page_type }}">
<span aria-label="hashtag">#</span>{{ tag.name|e('wp_kses_post')|raw }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
{% if ( is_document ) %}
{% set title = post.post_title|e('wp_kses_post') %}
<a
href="{{ post_link }}"
class="search-result-item-headline"
data-ga-category="Search Results"
data-ga-action="Title"
data-ga-label="{{ ga_page_type }}">
{{ title|raw|length > 30 ? ( title|striptags|slice(0, 30) ~ '...' )|raw : title|raw }}
</a>
{% elseif ( is_archive ) %}
<a
href="{{ post_link }}"
target="_blank"
class="search-result-item-headline archive"
data-ga-category="Search Results"
data-ga-action="Title"
data-ga-label="{{ ga_page_type }}">
{{ post.post_title|e('wp_kses_post')|raw }}
</a>
{% else %}
<a
href="{{ post_link }}"
class="search-result-item-headline"
data-ga-category="Search Results"
data-ga-action="Title"
data-ga-label="{{ ga_page_type }}">
{{ post.post_title|e('wp_kses_post')|raw }}
</a>
{% endif %}
</div>
<div>
{% if ( is_document ) %}
<a href="{{ post_link }}" download class="btn btn-small btn-secondary pdf-link" title="{{__('This link will open a PDF file', 'planet4-master-theme')}}">
{{ __( 'Download', 'planet4-master-theme' ) }}
</a>
{% elseif ( is_campaign or is_archive ) %}
<div class="search-results-alternative-label">
{% if is_campaign %}
{{ __( 'Campaign', 'planet4-master-theme' ) }}
{% elseif is_archive %}
{{ __( 'Archive', 'planet4-master-theme' ) }}
{% endif %}
</div>
{% endif %}
</div>
</div>
{% if ( post.post_excerpt|striptags|trim ) %}
<p class="search-result-item-content">
{{ post.post_excerpt|default(post.post_content)|excerpt( 30 )|raw }}
</p>
{% endif %}
{% if ( 'page' != post.post_type ) %}
<div class="search-result-item-info">
<span class="search-result-item-date">{{ post.post_date|date('d/m/Y') }}</span>
</div>
{% endif %}
{% if ( is_action ) %}
<div>
<a
href="{{ post_link }}"
class="btn btn-primary btn-small"
data-ga-category="Search Results"
data-ga-action="Call to Action"
data-ga-label="{{ ga_page_type }}">
{{ post.button_text }}
</a>
</div>
{% endif %}
{% if post.edit_link %}
<a href="{{ post.edit_link|raw }}">{{ __('Manage', 'planet4-master-theme') }}</a>
{% endif %}
</div>
</li>
{% if ( ( loop.index0 % 5 == 4 ) or loop.last ) %}
</div>
{% endif %}