-
Notifications
You must be signed in to change notification settings - Fork 3
/
record.twig
executable file
·124 lines (104 loc) · 5.59 KB
/
record.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
{% include 'partials/_header.twig' %}
<body>
{% set ids = [] %}
{% include 'partials/_navbar.twig' %}
<div class="container-fluid">
<div class="row">
{# first wide column with record content #}
{# ------------------------------------- #}
<div class="col-sm-12 col-md-9 col-lg-6 col-xl-6">
<div class="card">
<div class="card-block">
{# datepublish, author, tags #}
{# ------------------------- #}
<p>
<small class="text-muted"><strong>{{ record.datepublish|localedatetime("%A %B %e") }}</strong> by {{ record.user.username }}<br>
{% if record.taxonomy.tags is defined %}
{% for tag in record.taxonomy.tags %}
<a href="{{ paths.root }}tags/{{ tag }}"><span class="tags">{{ tag }}</span></a>
{% endfor %}
{% endif %}
</small>
</p>
{# title #}
{# ----- #}
<h4 class="card-title">{{ record.title }}</h4>
{# image #}
{# ----- #}
{% if record.image is not empty %}
{# Get width and height of origin via imageinfo #}
{% set oimage = {'height': imageinfo(record.image).height, 'width': imageinfo(record.image).width } %}
{# Set breakpoints (widths), change values for your own breakpoints #}
{% set rwidth = {'small': '480', 'medium': '640', 'large': '1024', 'xlarge': '1400'} %}
{# Calculate individual image heights for breakpoints (proportional) #}
{% set rheight = {'small': oimage.height*rwidth.small/oimage.width, 'medium': oimage.height*rwidth.medium/oimage.width, 'large': oimage.height*rwidth.large/oimage.width, 'xlarge': oimage.height*rwidth.xlarge/oimage.width } %}
<picture>
<source media="(max-width: {{rwidth.small}}{{'px'}})" srcset="{{ record.image|thumbnail(rwidth.small, rheight.small, 'r') }}">
<source media="(max-width: {{rwidth.medium}}{{'px'}})" srcset="{{ record.image|thumbnail(rwidth.medium, rheight.medium, 'r') }}">
<source media="(max-width: {{rwidth.large}}{{'px'}})" srcset="{{ record.image|thumbnail(rwidth.large, rheight.large, 'r') }}">
<source media="(max-width: {{rwidth.xlarge}}{{'px'}})" srcset="{{ record.image|thumbnail(rwidth.xlarge, rheight.xlarge, 'r') }}">
<img src="{{ record.image|thumbnail(rwidth.xlarge, rheight.xlarge, 'r') }}" alt="{{ record.imagetitle }}">
</picture>
{# caption #}
{# ------- #}
{# you will need to define a image caption text field in your contenttype #}
{# to make this showing up, default bolt install has no caption per image #}
{% if record.imagecaption %}<p class="small">{{ record.imagecaption }}</p>{% endif %}
{% endif %}
{# text #}
{# ---- #}
<p class="card-text">{{ record.body }}</p>
</div>
</div>
</div>
{# second column with related stuff if available #}
{# --------------------------------------------- #}
<div class="col-sm-12 col-md-3 col-lg-3 col-xl-3">
{# link to related page #}
{# -------------------- #}
{% set relatedrecords = record.related() %}
{% if relatedrecords is not empty %}
<div class="card">
<div class="card-block">
{% for related in relatedrecords %}
<h4 class="card-title"><a href="{{ related.link }}">{{ related.title }}</a></h4>
{% endfor %}
</div>
</div>
<p></p>
{% endif %}
{# show other records with same tags #}
{# --------------------------------- #}
{% if record.taxonomy.tags is defined %}
<div class="card">
<div class="card-block">
<h4>Related by tags</h4>
{% set alreadyhere = [] %}
{% set whichtags = [] %}
{% for tag in record.taxonomy.tags %}
{% setcontent tagrelatedrecords = 'entries' where { id: '!'~record.id~'' } %}
{% for related in tagrelatedrecords %}
{% if (tag) in related.taxonomy.tags and (related.id) not in alreadyhere %}
{% if (tag) not in whichtags %}<span class="tags">{{ tag }}</span>{% endif %}
<h4><a href="{{ related.link }}">{{ related.title }}</a></h4>
{% set alreadyhere = alreadyhere|merge([related.id]) %}
{% set whichtags = whichtags|merge([tag]) %}
{% endif %}
{% endfor %}
{% endfor %}
</div>
</div>
<p></p>
{% endif %}
</div>
{# third column with single blocks #}
{# ------------------------------- #}
<div class="col-sm-12 col-md-3 col-lg-3 col-xl-3">
{% for block in theme.blockcolumn %}
{% setcontent card = block %}
{% include 'partials/_card_simple.twig' %}
{% endfor %}
</div>
</div>
</div>
{% include 'partials/_footer.twig' %}