-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearch.twig
64 lines (52 loc) · 2.07 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
{% include 'partials/_header.twig' %}
<body>
{% include 'partials/_navbar.twig' %}
<div class="container-fluid">
<div class="row" style="padding-left: 20px; padding-bottom: 20px">
<div>
{% if search is not empty %}
<h2>{{ __('general.phrase.search-results-for-variable', { '%search%': search }) }}</h2>
{% else %}
<h2>{{ __('general.phrase.search') }}</h2>
{% endif %}
</div>
</div>
</div>
{% 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_search.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 %}
{% include 'partials/_sub_pager_mobile.twig' %}
{% endif %}
</div>
{% include 'partials/_footer.twig' %}