Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f54429c

Browse files
wachterjohannesniklasnatter
authored andcommittedOct 21, 2020
02 - Add a content block to the homepage
1 parent f1c945f commit f54429c

File tree

7 files changed

+156
-0
lines changed

7 files changed

+156
-0
lines changed
 

‎config/image-formats.xml

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
<scale x="1920"/>
2424
</format>
2525

26+
<format key="200x">
27+
<meta>
28+
<title lang="en">Block Image</title>
29+
<title lang="de">Block Bild</title>
30+
</meta>
31+
32+
<scale x="200"/>
33+
</format>
34+
2635
<!--
2736
Render an image from the media_selection in a specific format the following way:
2837

‎config/templates/pages/homepage.xml

+94
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,99 @@
6060
<title lang="de">Veranstaltungs Highlights</title>
6161
</meta>
6262
</property>
63+
64+
<block name="blocks" default-type="text-image">
65+
<types>
66+
<type name="text-image">
67+
<meta>
68+
<title lang="en">Text image</title>
69+
<title lang="de">Text image</title>
70+
</meta>
71+
72+
<properties>
73+
<property name="title" type="text_line">
74+
<meta>
75+
<title lang="en">Title</title>
76+
<title lang="de">Titel</title>
77+
</meta>
78+
</property>
79+
80+
<property name="article" type="text_editor">
81+
<meta>
82+
<title lang="en">Article</title>
83+
<title lang="de">Artikel</title>
84+
</meta>
85+
</property>
86+
87+
<property name="image" type="single_media_selection">
88+
<meta>
89+
<title lang="en">Image</title>
90+
<title lang="de">Bild</title>
91+
</meta>
92+
93+
<params>
94+
<param name="types" value="image"/>
95+
96+
<param name="defaultDisplayOption" value="left"/>
97+
<param name="displayOptions" type="collection">
98+
<param name="left" value="true" />
99+
<param name="right" value="true" />
100+
</param>
101+
</params>
102+
</property>
103+
</properties>
104+
</type>
105+
106+
<type name="quote">
107+
<meta>
108+
<title lang="en">Quote</title>
109+
<title lang="de">Zitat</title>
110+
</meta>
111+
112+
<properties>
113+
<property name="quote" type="text_area">
114+
<meta>
115+
<title lang="en">Quote</title>
116+
<title lang="de">Zitat</title>
117+
</meta>
118+
</property>
119+
120+
<property name="author" type="text_line">
121+
<meta>
122+
<title lang="en">Author</title>
123+
<title lang="de">Autor</title>
124+
</meta>
125+
</property>
126+
</properties>
127+
</type>
128+
129+
<type name="gallery">
130+
<meta>
131+
<title lang="en">Gallery</title>
132+
<title lang="de">Galerie</title>
133+
</meta>
134+
135+
<properties>
136+
<property name="title" type="text_line">
137+
<meta>
138+
<title lang="en">Title</title>
139+
<title lang="de">Titel</title>
140+
</meta>
141+
</property>
142+
143+
<property name="images" type="media_selection">
144+
<meta>
145+
<title lang="en">Images</title>
146+
<title lang="de">Bilder</title>
147+
</meta>
148+
149+
<params>
150+
<param name="types" value="image"/>
151+
</params>
152+
</property>
153+
</properties>
154+
</type>
155+
</types>
156+
</block>
63157
</properties>
64158
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="row">
2+
<h3>{{ content.title }}</h3>
3+
</div>
4+
5+
<div class="row">
6+
<div>
7+
{% for image in content.images %}
8+
<img src="{{ image.formats['200x'] }}" alt="{{ image.title }}" class="img-thumbnail m-3">
9+
{% endfor %}
10+
</div>
11+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="row">
2+
<blockquote class="blockquote text-center">
3+
<p class="mb-0">{{ content.quote }}</p>
4+
<footer class="blockquote-footer">{{ content.author }}</footer>
5+
</blockquote>
6+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="row">
2+
{% set imageContainer %}
3+
{%- if content.image %}
4+
<div class="col-3">
5+
<img src="{{ content.image.formats['200x'] }}" class="img-fluid rounded" alt="{{ content.image.title }}">
6+
</div>
7+
{% endif -%}
8+
{% endset %}
9+
10+
{% if view.image.displayOption == 'left' %}
11+
{{ imageContainer|raw }}
12+
{% endif %}
13+
14+
<div class="{{ imageContainer ? 'col-9' : 'col-12'}}">
15+
<h3>{{ content.title }}</h3>
16+
17+
{{ content.article|raw }}
18+
</div>
19+
20+
{% if view.image.displayOption == 'right' %}
21+
{{ imageContainer|raw }}
22+
{% endif %}
23+
</div>

‎templates/includes/blocks.html.twig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% for block in content.blocks %}
2+
<section class="container mt-5 clearfix">
3+
{% include "includes/block-types/#{block.type}.html.twig" with {
4+
content: block,
5+
view: view.blocks[loop.index0],
6+
} only %}
7+
</section>
8+
{% endfor %}

‎templates/pages/homepage.html.twig

+5
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@
2626
{% endfor %}
2727
</div>
2828
</div>
29+
30+
{% include 'includes/blocks.html.twig' with {
31+
content: {blocks: content.blocks},
32+
view: {blocks: view.blocks},
33+
} only %}
2934
{% endblock %}

0 commit comments

Comments
 (0)
Please sign in to comment.