Skip to content

Commit 27da3a4

Browse files
committed
[TASK] Update Content Mapping to use Site Package Builder
Releases: main, 13.4
1 parent cad43e7 commit 27da3a4

File tree

6 files changed

+65
-175
lines changed

6 files changed

+65
-175
lines changed

Documentation/ContentMapping/Index.rst

Lines changed: 64 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,49 @@
77
Display the content elements on your page
88
=========================================
99

10-
In step :ref:`create-section` we moved the part of our template, that will
11-
contain the content, into its own section. This section is however still filled
12-
with dummy content:
10+
In step `The page view <https://docs.typo3.org/permalink/t3sitepackage:pageview>`_
11+
we had a first look at the TypoScript configuration for the page view.
1312

14-
.. literalinclude:: _codesnippets/_SectionMain.html
15-
:caption: Resources/Private/PageView/Pages/Default.html
13+
Now let us see how the content is mapped to its position in the templates.
1614

1715
.. contents::
1816

1917
.. _content-mapping-site-set:
2018

21-
Include the site sets of fluid-styled-content as dependency
22-
===========================================================
19+
Dependency on Fluid Styled Content
20+
==================================
2321

24-
In step :ref:`Minimal site package - Create a basic site
25-
set <t3sitepackage:minimal-extension-siteset>` we created a basic site set for
26-
our site package.
27-
28-
Add a dependency to the sets provided by the system extension
29-
:composer:`typo3/cms-fluid-styled-content`. This step is a prerequisite to
30-
display the content in the next steps.
31-
32-
Your site set configuration should now look like this:
22+
In step `Look at the a basic site set <https://docs.typo3.org/permalink/t3sitepackage:minimal-extension-siteset>`_
23+
We inspected site set configuration that was generated for you by the Site
24+
Package Builder. Now let us have another look:
3325

3426
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/config.yaml
3527
:caption: packages/my_site_package/Configuration/Sets/SitePackage/config.yaml
3628
:language: yaml
3729
:linenos:
30+
:emphasize-lines: 3-5
31+
32+
In lines 3-5 a dependency to the sets provided by the system extension
33+
:composer:`typo3/cms-fluid-styled-content` is defined. These sets define
34+
default Fluid templates and very basic CSS for your site. Without using such
35+
an extension you would have to define all content elements and their rendering
36+
yourself.
3837

3938
.. _cm-dynamic-content-rendering-in-typoscript:
4039
.. _backend-page-layouts:
4140
.. _content-mapping-backend-layout:
4241

43-
Create a default page layout with page TSconfig
44-
===============================================
45-
46-
In order to map the content from the backend to the frontend we create a
47-
new file :file:`Configuration/Sets/SitePackage/page.tsconfig` containing :ref:`page TSconfig <t3tsref:setting-page-tsconfig>`.
48-
49-
.. todo: Link to page TSconfig description in getting started once chapter exist.
42+
The page layout / backend layout
43+
================================
5044

51-
By placing the file within the site set, you created in step
52-
:ref:`Create a basic site set <t3sitepackage:minimal-extension-siteset>`, the
53-
newly created file is loaded within the page tree of your site automatically:
45+
The :ref:`page TSconfig <t3tsref:setting-page-tsconfig>` definition in :
46+
file:`Configuration/Sets/SitePackage/PageTsConfig/BackendLayouts/default.tsconfig`
47+
contains our default page layout. For historic reasons this setting is also
48+
called "backend layout", even though it influences the page layouts of both
49+
the :guilabel:`Web > Page` module as well as the output of a page in the frontend.
5450

55-
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/page.tsconfig
56-
:caption: packages/my_site_package/Configuration/Sets/SitePackage/page.tsconfig
57-
:linenos:
58-
59-
This file automatically includes all `.tsconfig` files from the designated folder
60-
in which we will store the page layouts.
61-
62-
We now create a default page layout with two areas: One for the main content and
63-
one for the stage.
64-
65-
.. literalinclude:: _codesnippets/_Default.tsconfig
66-
:language: typoscript
67-
:caption: packages/my_site_package/Configuration/TsConfig/Page/PageLayout/Default.tsconfig
51+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/PageTsConfig/BackendLayouts/default.tsconfig
52+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/PageTsConfig/BackendLayouts/default.tsconfig
6853
:linenos:
6954

7055
.. versionchanged:: TYPO3 13
@@ -90,17 +75,13 @@ properties at :guilabel:` Appearance > Page Layout > Backend Layout`.
9075
.. figure:: /Images/AutomaticScreenshots/ChooseBackendLayout.png
9176
:class: with-shadow
9277

93-
Choose the backend layout
78+
Choose the page / backend layout
9479

9580
.. _choose_page_layout:
9681

9782
Choose the page layout in the page properties
9883
---------------------------------------------
9984

100-
Switch to the new backend layout and save the page properties. In the
101-
:guilabel:`Page` module you will see two areas called "Stage" and
102-
"Main Content" now.
103-
10485
If you followed step
10586
:ref:`Load the example data automatically <t3sitepackage:load-example-data>`
10687
the areas "Stage" and "Main" should already contain some example content.
@@ -131,24 +112,25 @@ Content rendering via page-content data processor
131112
If you are using TYPO3 v12.4 read :ref:`content element mapping in TYPO3
132113
v12.4 <t3sitepackage/12:cm-typo3-backend-create-pages>`
133114

134-
The TypoScript object :ref:`PAGEVIEW <t3tsref:cobj-pageview>`, that we
135-
defined in step :ref:`Fluid version of the minimal
136-
site package <t3sitepackage:minimal-extension-fluid>` enables us to introduce
137-
a data processor to facilitate content mapping.
115+
The TypoScript object :ref:`PAGEVIEW <t3tsref:cobj-pageview>`, defined in the
116+
TypoScript file :file:`Configuration/Sets/SitePackage/TypoScript/page.typoscript`,
117+
uses a data processor to facilitate content mapping.
138118

139-
Edit the TypoScript configuration of the `PAGEVIEW` object to define a
140-
data processor of type :ref:`page-content <t3tsref:PageContentFetchingProcessor>`:
119+
The used data processor is of type :ref:`page-content <t3tsref:PageContentFetchingProcessor>`-
141120

142-
.. literalinclude:: _codesnippets/_pageview.diff
143-
:caption: Configuration/Sets/SitePackage/setup.typoscript (diff)
121+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript
122+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript
123+
:linenos:
124+
:emphasize-lines: 12
144125

145-
This data processor provides the variable `content` to your Fluid template.
126+
This data processor provides the variable `content` to your Fluid template. It
127+
needs no further configuration.
146128

147129
You can debug this variable in the main section of your template using the
148130
:ref:`Debug ViewHelper <f:debug> <t3viewhelper:typo3-fluid-debug>`:
149131

150132
.. literalinclude:: _codesnippets/_SectionMainDebug.diff
151-
:caption: Resources/Private/PageView/Pages/Default.html
133+
:caption: Resources/Private/PageView/Pages/Default.html (diff)
152134

153135
The debug output after clearing all caches and previewing the page should look
154136
like this:
@@ -170,70 +152,48 @@ like this:
170152

171153
.. _cm-fluid-typoscript-mapping:
172154

173-
TypoScript mapping in Fluid template
174-
====================================
175-
176-
Open the file :file:`Resources/Private/PageView/Page/Default.html` and locate the
177-
main content area. It contains a headline (look for the :code:`<h2>`-tags) and
178-
some dummy content (look for the :code:`<p>`-tags).
155+
Map the content areas to their respective section in the page template
156+
======================================================================
179157

180-
Replace these lines with a :ref:`Fluid for-loop <t3viewhelper:typo3fluid-fluid-for>`,
181-
rendering each content element using the
182-
:ref:`CObject ViewHelper <f:cObject> <t3viewhelper:typo3-fluid-cobject>`:
183-
184-
.. literalinclude:: _codesnippets/_SectionMainRender.diff
185-
:caption: Resources/Private/PageView/Pages/Default.html (diff)
158+
Open the file :file:`packages/my_site_package/Resources/Private/PageView/Pages/Default.html`
159+
and locate the section called "Main".
186160

187-
For content elements the main type is always `tt_content`. Therefore we include
188-
the TypoScript object :typoscript:`tt_content` here. It is defined in the TypoScript
189-
of the system extension :composer:`typo3/cms-fluid-styled-content`. We included
190-
the site set of that extension in step :ref:`content-mapping-site-set`.
161+
It uses the `Render ViewHelper <f:render> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-render>`_
162+
to delegate rendering of the content elements of one section to the partial
163+
:file:`packages/my_site_package/Resources/Private/PageView/Partials/Content.html`.
191164

192-
`fluid-styled-content` internally uses
193-
Fluid templates and TypoScript with data processors just like the ones we were
194-
defining above. If you desire to change the output of these content elements
195-
you could override the Fluid templates of the extension
196-
:composer:`typo3/cms-fluid-styled-content`.
165+
.. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Pages/Default.html
166+
:caption: packages/my_site_package/Resources/Private/PageView/Pages/Default.html
167+
:linenos:
168+
:emphasize-lines: 7
197169

198-
.. _content-element-partial:
170+
As the main content area uses the content area defined with identifier `main`
171+
(compare section :ref:`backend-page-layouts`) variable `{content.main.records}`
172+
is used to display the content from the main area.
199173

200-
Extract the content element rendering to a partial
201-
==================================================
174+
Similarly the content from the stage is displayed:
202175

203-
As we want to reuse the Fluid part about rendering content elements in the
204-
next steps, we extract it into a partial, like we did with the menu in
205-
step :ref:`Extract the menu into a partial <t3sitepackage:create_partial_header>`.
176+
.. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Partials/Stage.html
177+
:caption: packages/my_site_package/Resources/Private/PageView/Partials/Stage.html
206178

207-
We want to be able to render content elements of **any content area**. Therefore pass
208-
the records of the page layout area to be rendered as variable `records` to
209-
the partial:
179+
.. _content-element-partial:
180+
.. _content-element-typoscript:
210181

211-
.. literalinclude:: _codesnippets/_SectionMainRenderPartial.diff
212-
:caption: Resources/Private/PageView/Pages/Default.html (diff)
182+
Delegate the rendering of the content elements to TypoScript
183+
============================================================
213184

214-
The partial then looks like this:
185+
In TYPO3 13 unfortunately there is at time of writing no easy way to render the
186+
content elements. We therefore have to delegate rendering of the single
187+
content elements to TypoScript by using the
188+
`CObject ViewHelper <f:cObject> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-cobject>`_:
215189

216190
.. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Partials/Content.html
217191
:caption: packages/my_site_package/Resources/Private/PageView/Partials/Content.html
218192
:linenos:
219193

220-
.. _content-element-typoscript:
221-
222-
Splitting up the TypoScript into files
223-
======================================
224-
225-
At this point the file `packages/my_site_package/Configuration/Sets/SitePackage/setup.typoscript`
226-
has started to have several lines. When we start rendering the
227-
`Menues <https://docs.typo3.org/permalink/t3sitepackage:main-menu-creation>`_,
228-
make more sophisticated
229-
`Settings <https://docs.typo3.org/permalink/t3sitepackage:site-sets-configuration>`_
230-
etc the TypoScript configuration file is going to grow more.
231-
We therefore suggest, to use TypoScript imports
232-
and structure your TypoScript in different files that are then combined at this point.
233-
234-
The rest of the Tutorial will assume that your files are in the directory
235-
:path:`packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/` and imported
236-
as described in `TypoScript imports <https://docs.typo3.org/permalink/t3sitepackage:typoscript-configuration>`_.
194+
Wherever we need to render the content elements of a section of the page we
195+
include this partial and pass the content elements to be rendered to it, just
196+
like we did in section
237197

238198
.. _content-element-next-steps:
239199

Documentation/ContentMapping/Stage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Page Layout with slide mode
1818

1919
The page layout contains a definition for the stage area in lines 10-19:
2020

21-
.. literalinclude:: _codesnippets/_Default.tsconfig
21+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/config.yaml
2222
:language: typoscript
2323
:caption: packages/my_site_package/Configuration/Sets/SitePackage/PageTsConfig/BackendLayouts/default.tsconfig
2424
:linenos:

Documentation/ContentMapping/_codesnippets/_Default.tsconfig

Lines changed: 0 additions & 34 deletions
This file was deleted.

Documentation/ContentMapping/_codesnippets/_SectionMain.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

Documentation/ContentMapping/_codesnippets/_SectionMainRender.diff

Lines changed: 0 additions & 16 deletions
This file was deleted.

Documentation/ContentMapping/_codesnippets/_pageview.diff

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)