-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisting.twig
134 lines (114 loc) · 4.68 KB
/
listing.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
{% extends 'partials/_master.twig' %}
{% block content %}
<div id="header">
{# If used for listing a taxonomy, we add a heading.: #}
{% if taxonomytype is defined %}
<h1>
{{ __('general.phrase.overview-for') }}
{% if taxonomy.options[slug]is defined %}
{{ taxonomy.options[slug] }}
{% else %}
{{ slug }}
{% endif %}
</h1>
{# Taxonomies are fetched unordered by design except if 'has_sortorder'
is set to true. This way we keep 'grouping' intact in the listing. #}
{% if not taxonomy.has_sortorder %}
{# If we specified an order in config.yml, sort them here, accordingly: #}
{% set records = records | order(config.get('general/listing_sort')) %}
{% endif %}
{% endif %}
{# if used for searches #}
{% if search is defined %}
<h1>
{{ __('general.phrase.search') }}
</h1>
<form method="get" action="{{ path('search') }}" id="searchform-inline" enctype="text/plain">
<div class="input-group">
<input type="text" value="{{ search|default() }}"
placeholder="{{ __('general.phrase.search-ellipsis') }}"
name="search"
class="form-input"
autofocus>
<button class="btn btn-primary input-group-btn">
{{ __('general.phrase.search') }}
</button>
</div>
</form>
{% endif %}
{# contenttype listing #}
{% if contenttype is defined %}
<h1>
{{ contenttype }}
</h1>
{% endif %}
</div>
{# BEGIN normal listing stuff #}
{% for record in records %}
{% if not record.contenttype.hide_in_listings %}
{# dont show anything if the contenttype has defined hide_in_listings = true #}
<div class="columns list-item">
<div class="column col-7 col-sm-12">
{% if not record.contenttype.hide_publish_date %}
{{ record.datepublish|localedatetime("%d.%m.%Y") }}
{% endif %}
{% if record.use_password_protection %}
<i class="fa fa-lock"></i>
{% endif %}
<h2 class="post-title">
<a href="{{ record.link }}">
{{ record.title }}
</a>
</h1>
<p class="post-teaser">
<a href="{{ record.link }}" class="readmore">
{# generate the teaser text #}
{% if record.introduction %}
{% set teaser = record.introduction %}
{% elseif record.teaser and record.teaser != "" %}
{% set teaser = record.teaser %}
{% else %}
{% set teaser = (record.body ~ record.content)|excerpt(250, false, search|default('')) %}
{% endif %}
{{ teaser }}
{#
in fact we dont want to show teaser to users not logged in
(if the record itself is password protected, of course)
but we are not able to call a function ONLY IF the extension is installed (and therefore the function is available/defined)
{% if record.use_password_protection %}
{% if app.extensions.get('Bobdenotter/PasswordProtect') is not null %}
{% if passwordprotect_username() %}
{{ teaser }}
{% endif %}
{% endif %}
{% else %}
{{ teaser }}
{% endif %}
#}
</a>
</p>
</div>
<div class="column col-5 col-sm-12">
{% if record.image %}
<img src="{{ thumbnail(record.image, 'listing_600w') }}"
class="img-responsive"
srcset="{{ thumbnail(record.image, 'listing_250w') }} 250w,
{{ thumbnail(record.image, 'listing_350w') }} 350w,
{{ thumbnail(record.image, 'listing_600w') }} 600w">
{% endif %}
</div>
</div>
{% endif %}
{% else %}
<div class="post">
<h1 class="post-title">
{{ __('general.phrase.no-content-found') }}
</h1>
<p>
{{ __("Unfortunately, no content could be found. Try another page, or go to the <a href=\"%paths_root%\">homepage</a>.", {'%paths_root%': path('homepage')} ) }}
</p>
</div>
{% endfor %}
{# If there are more records than will fit on one page, the pager is shown. #}
{{ pager(template = 'partials/_pager.twig') }}
{% endblock content %}