-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlisting.twig
82 lines (68 loc) · 3.04 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
{% include 'partials/_header.twig' %}
<body>
{% include 'partials/_navbar.twig' %}
<div class="container-fluid">
<div class="row col-12" style="padding-left: 20px; padding-bottom: 20px">
{# This template is used for 'listings': Generic pages that list a number of
records from a certain contenttype. These records are available as an array
called 'records'. In the for-loop below, we iterate over the records that
are on this page. It can be used for overview pages like 'all entries', or
'all records tagged with kittens'. #}
{# If used for listing a taxonomy, we add a heading.: #}
{% if taxonomytype is defined %}
<h2>
{{ __('general.phrase.overview-for') }}
{% if taxonomy.options[slug] is defined %}
<mark>{{ taxonomy.options[slug] }}</mark>
{% else %}
<mark>{{ slug }}</mark>
{% endif %}
</h2>
{# 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(app.config.get('general/listing_sort')) %}
{% endif %}
{% endif %}
</div>
</div>
<p></p>
{% set cards = records %}
{# getting the magic with rows and columns #}
{# i.e. 10 entries should give = 3/3/2/2, not 3/3/3/1 #}
{# -------------------------------------------------- #}
{% if cards|length > 4 %}
{% set rows = (cards|length)//4 %}
{% set d = (cards|length)-(rows*4) %}
{% set magic = [ [0,rows+(d//d)], [rows+(d//d), rows+(d//2)|round(0,'floor')], [2*rows+(d//1.5|round(0,'ceil'))+(d//d), rows+(d//3|round(0,'floor'))], [(3*rows)+d, rows] ] %}
{% else %}
{% set magic = [ [0,1], [1,1], [2,1], [3,1] ] %}
{% endif %}
{# container #}
{# --------- #}
<div class="container-fluid">
<div class="row">
{# get the 4 columns #}
{% for key in magic|keys %}
<div id="column-{{key}}" class="col-sm-12 col-md-6 col-lg-4 col-xl-3">
{# push rows in columns #}
{% for card in cards|slice(magic[key][0],magic[key][1]) %}
{% include 'partials/_card_list.twig' %}
{% endfor %}
{# pager desktop #}
{% if loop.last %}
{% if theme.pagerdesktop %}
{% include 'partials/_sub_pager_desktop.twig' %}
{% endif %}
{% endif %}
</div>
{% endfor %}
</div>
</div>
{# pager mobile #}
{% if theme.pagermobile %}
{{ pager('', '', 'partials/_sub_pager_mobile.twig') }}
{% endif %}
</div>
{% include 'partials/_footer.twig' %}