Skip to content

Commit ebcbfa2

Browse files
[TASK] Update chapter on jumbotron for TYPO3 13.4 (#247)
Releases: main, 13.4 Co-authored-by: lina.wolf <[email protected]>
1 parent 1300012 commit ebcbfa2

File tree

3 files changed

+64
-47
lines changed

3 files changed

+64
-47
lines changed

Documentation/CodeSnippets/Fluid/PartialJumbotron.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
:caption: EXT:site_package/Resources/Private/Templates/Partials/Jumbotron.html
66
:linenos:
77

8-
<f:for each="{records}" as="record">
8+
<f:for each="{content.jumbotron.records}" as="record">
99
<div class="container">
1010
<div class="p-5 mb-4 bg-body-tertiary">
1111
<div class="container-fluid py-5">
1212
<h1 class="display-5 fw-bold">{record.header}</h1>
13-
<p class="col-md-8 fs-4"><f:format.stripTags>{record.bodytext}</f:format.stripTags></p>
13+
<p class="col-md-8 fs-4"><f:format.html>{record.bodytext}</f:format.html></p>
1414
<button class="btn btn-dark btn-lg" role="button" href="#" id="exampleButton">Example button</button>
1515
</div>
1616
</div>

Documentation/CodeSnippets/Fluid/TemplateDefault.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<f:layout name="Layout"/>
99
<f:section name="Main">
1010

11-
<f:render partial="Jumbotron" arguments="{records: content.jumbotron.records}"/>
11+
<f:render partial="Jumbotron" arguments="{_all}"/>
1212

1313
<div class="container">
1414
<f:render partial="Content" arguments="{records: content.main.records}"/>

Documentation/ContentMapping/Jumbotron.rst

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,83 @@
77
The jumbotron: Customize output of content elements
88
===================================================
99

10-
As you can see in the static html template, the jumbotron consist of a headline
11-
and a text:
10+
.. contents::
1211

13-
.. code-block:: html
14-
:caption: theme/index.html
12+
.. _jumbotron-partial:
1513

16-
<div class="jumbotron">
17-
<div class="container">
18-
<h1 class="display-3">Hello, world!</h1>
19-
<p> ... </p>
20-
</div>
21-
</div>
14+
The jumbotron partial template
15+
==============================
2216

23-
We could use a content element of type :guilabel:`Text` to store the needed
24-
information. However the output of the default content element "Text" looks
25-
like this:
17+
The partial of the jumbotron that we created in step
18+
:ref:`Split up the template into partials <t3sitepackage:partials>` still
19+
contains static content:
2620

2721
.. code-block:: html
28-
:caption: Example HTML Output
29-
30-
<div id="c215" class="frame frame-default frame-type-text frame-layout-0">
31-
<header>
32-
<h2 class="">
33-
Hello World!
34-
</h2>
35-
</header>
36-
<p>Lorem ipsum dolor sit amet, ...</p>
22+
:caption: packages/site_package/Resources/Private/Templates/Partials/Jumbotron.html
23+
24+
<div class="container">
25+
<div class="p-5 mb-4 bg-body-tertiary">
26+
<div class="container-fluid py-5">
27+
<h1 class="display-5 fw-bold">Custom jumbotron</h1>
28+
<p class="col-md-8 fs-4">This jumbotron contains a button to demonstrate that JavaScript is working: </p>
29+
<button class="btn btn-dark btn-lg" role="button" href="#" id="exampleButton">Example button</button>
30+
</div>
3731
</div>
3832

39-
Also we do not want to output other types of content like images or forms.
33+
.. _jumbotron-content-records:
4034

41-
Open the partial displaying the jumbotron:
42-
:file:`Resources/Private/Partials/Page/Jumbotron.html`. We already have the
43-
data of content elements in the column "jumbotron" in a Fluid variable called
44-
"jumbotronContent".
35+
Jumbotron content records
36+
=========================
37+
38+
In our Fluid template the variable the variable `{content.jumbotron.records}`
39+
already contains the content of the content elements entered in columns
40+
`jumbotron` in the TYPO3 backend. This column was defined in the
41+
:ref:`Page layout <t3sitepackage:content-mapping-backend-layout>`. It is provided
42+
by the :ref:`page-content data processor <t3sitepackage:page-content-data-processor>`.
4543

46-
Now instead of letting extension :file:`fluid_styled_content` render the
47-
content we will render it ourselves in this partial. Add the debug view helper
48-
to the partial to see what the data of the jumbotronContent looks like:
44+
Open the partial displaying the jumbotron:
45+
:file:`Resources/Private/Partials/Page/Jumbotron.html`. Using the
46+
:ref:`Debug ViewHelper <f:debug> <t3viewhelper:typo3-fluid-debug>` have a look
47+
at what kind of data is passed to your partial template:
4948

5049
.. code-block:: html
5150
:caption: EXT:site_package/Resources/Private/Partials/Page/Jumbotron.html
5251

52+
<f:debug>{content.jumbotron.records}</f:debug>
5353
<div class="jumbotron">
54-
<f:debug>{jumbotronContent}</f:debug>
5554
<!-- ... -->
5655
</div>
5756

58-
As you can see the data of the actually :sql:`tt_content` record can be found in
59-
:typoscript:`data`. Now let us traverse the array and output the content
60-
elements:
57+
.. _jumbotron-customized-rendering:
6158

62-
.. code-block:: html
63-
:caption: EXT:site_package/Resources/Private/Partials/Page/Jumbotron.html
59+
Customized rendering of the content records
60+
===========================================
6461

65-
<div class="jumbotron">
66-
<f:for each="{jumbotronContent}" as="contentElement">
67-
<div class="container">
68-
<h1 class="display-3">{contentElement.data.header}</h1>
69-
<f:format.html>{contentElement.data.bodytext}</f:format.html>
70-
</div>
71-
</f:for>
72-
</div>
62+
The variable will contain an array of :php:`\TYPO3\CMS\Core\Domain\Record`
63+
elements. If the array is empty. Check that your page indeed has content in
64+
the column "Jumbotron".
65+
66+
You could render these content elements the way that we rendered the main content
67+
(compare :ref:`Extract the content element rendering to a
68+
partial <t3sitepackage:content-element-partial>`). However our expected HTML
69+
output is different from what fluid-styled-content produces out-of-the-box.
70+
71+
Instead of letting the system extension fluid-styled-content render the
72+
content we will render it ourselves in this partial.
73+
74+
We traverse the array provided by the page-content data processor and render
75+
the content ourselves:
76+
77+
.. include:: /CodeSnippets/Fluid/PartialJumbotron.rst.txt
78+
79+
The :ref:`For ViewHelper <f:for> <t3viewhelper:typo3fluid-fluid-for>` loops
80+
through all content elements in column jumbotron and provides them in variable
81+
`{record}`.
82+
83+
The :php-short:`\TYPO3\CMS\Core\Domain\Record` object contains the information
84+
of the database row representing the current content element record.
85+
For advanced usage see :ref:`Use records in Fluid <t3coreapi:record_objects_fluid>`.
86+
87+
Here we use the fields `header` and `bodytext` of the record. As the `bodytext`
88+
field has a rich-text editor in the backend, we pass it through the
89+
:ref:`Format.html ViewHelper <f:format.html> <t3viewhelper:typo3-fluid-format-html>`.

0 commit comments

Comments
 (0)