Skip to content

Commit 078b9f7

Browse files
committed
[TASK] Document using site settings
Releases: main, 13.4
1 parent a0a1270 commit 078b9f7

File tree

4 files changed

+139
-15
lines changed

4 files changed

+139
-15
lines changed
30.9 KB
Loading

Documentation/SiteSets/Index.rst

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ our site package.
1818

1919
In step :ref:`content-mapping-site-set` we added dependencies to our site set.
2020

21-
.. contents::
21+
.. contents:: Table of Contents
22+
23+
.. toctree::
24+
:titlesonly:
25+
:glob:
26+
27+
*/Index
2228

2329
.. _site_set:
2430

@@ -87,17 +93,5 @@ Here we override some values for maximal image width in text-media content
8793
elements, we enable a lightbox for images and set paths for overriding the
8894
templates of that extension.
8995

90-
.. _settings-definitions-yaml-constants:
91-
92-
Setting definition
93-
==================
94-
95-
Settings definitions are used to set values that can be used in the TypoScript
96-
setup through out the project. Before they were kept in the file
97-
:file:`constants.typoscript`. Since TYPO3 v13 they can be stored in the file
98-
:file:`settings.definitions.yaml`. See
99-
`settings.definitions.yaml <https://github.com/TYPO3-Documentation/TYPO3CMS-Tutorial-SitePackage-Code/blob/main/Configuration/Sets/SitePackage/settings.definitions.yaml>`__ in Github.
100-
101-
It is best practice to use them for values that might
102-
want to be changed later on like paths, ids of important pages (contact,
103-
imprint, a system folder that contains certain records, ...).
96+
Settings can also be used in conditions:
97+
`Check if a setting/constant is set to a certain value <https://docs.typo3.org/permalink/t3tsref:condition-examples-constant>`_.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
:navigation-title: Usage in Fluid
2+
3+
.. include:: /Includes.rst.txt
4+
.. _settings-fluid:
5+
6+
=============================================
7+
How to use settings as variables in templates
8+
=============================================
9+
10+
Certain information is used in different parts of the templates over and over
11+
again like the uid of the data privacy page or the contact e-mail address.
12+
13+
You can keep central information in settings. They can then be adjusted as
14+
needed in the :guilabel:`Site Management > Settings` module in the backend
15+
by administrators.
16+
17+
.. _settings-definitions-yaml-constants:
18+
19+
Setting definition
20+
==================
21+
22+
Settings definitions are used to set values that can be used in the TypoScript
23+
setup through out the project.
24+
25+
They are stored in the file :file:`settings.definitions.yaml` in your site set.
26+
27+
The settings can be displayed and adjusted in module
28+
:guilabel:`Site Management > Settings`:
29+
30+
.. figure:: /Images/Settings/SitePackageSettings.png
31+
:alt: Screenshot of module "Site Management > Settings" with the settings of the example site package open
32+
33+
Administrators can view and adjust settings and save them here.
34+
35+
If administrators change settings here, they get saved to
36+
:file:`config/sites/my-site/settings.yaml` so this path and file have to be
37+
writable for TYPO3. If the file is not writable for example when you have it
38+
under version control, administrators can als export the settings and download
39+
them.
40+
41+
Let us have a look at the example generated by the
42+
`Site Package Builder <https://get.typo3.org/sitepackage>`_:
43+
44+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/settings.definitions.yaml
45+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/settings.definitions.yaml
46+
47+
Settings can be assigned to categories so that they are easier to find for
48+
administrators. These categories are defined in lines 1-12.
49+
50+
Let us now have a look at the definition of a setting entry in detail:
51+
52+
.. literalinclude:: _setting_entry.yaml
53+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/settings.definitions.yaml (excerpt)
54+
55+
Line 1 defines the identifier of the settings. Identifiers are available
56+
globally within the complete project and installed extensions might define some.
57+
Use a unique prefix therefore. Here we use `MySitePackage.`. We used the same
58+
prefix for the categories. This is suggested but not mandatory in a site package.
59+
60+
Line 2-3 define labels to be displayed in the backend module.
61+
62+
Line 4 sets the category.
63+
64+
Line 5 sets the type. See all available types here:
65+
`Site setting definition types <https://docs.typo3.org/permalink/t3coreapi:definition-types>`_.
66+
67+
Line 6 defines a default. If you define a default its type in YAML
68+
**has to match** the type defined in line 5.
69+
70+
All properties that can be defined for setting definitions can be found here:
71+
`Site setting definition properties <https://docs.typo3.org/permalink/t3coreapi:site-settings-definition-properties>`_.
72+
73+
.. seealso::
74+
* `Site settings definitions <https://docs.typo3.org/permalink/t3coreapi:site-settings-definition>`_
75+
* `Configuring the site settings editor <https://docs.typo3.org/permalink/t3coreapi:sitehandling-settings-editor-configuration>`_
76+
* `Site management: Trouble shooting <https://docs.typo3.org/permalink/t3start:site-management-trouble>`_
77+
78+
.. _usage-settings-fluid:
79+
80+
Using setting entries in a Fluid template
81+
=========================================
82+
83+
The site settings are available as variable `{settings}`
84+
(see :ref:`settings <t3tsref:confval-pageview-data-settings>`) within the templates
85+
of the page as we as we are using the `PAGEVIEW <https://docs.typo3.org/permalink/t3tsref:cobj-pageview>`_
86+
TypoScript object.
87+
88+
In the site package example we display the logo once in the header in large and
89+
once in the footer in smaller and use the settings to determine the path and alt
90+
text in both cases:
91+
92+
.. literalinclude:: /CodeSnippets/my_site_package/Resources/Private/PageView/Partials/Footer.html
93+
:caption: packages/my_site_package/Resources/Private/PageView/Partials/Footer.html
94+
95+
At the time of writing the settings are not available out-of-the-box in
96+
templates configured by `FLUIDTEMPLATE <https://docs.typo3.org/permalink/t3tsref:cobj-template>`_
97+
objects, for example in
98+
`custom content element templates <https://docs.typo3.org/permalink/t3sitepackage:content-element-rendering>`_
99+
or within `Custom Content Blocks <https://docs.typo3.org/permalink/t3sitepackage:content-blocks>`_.
100+
You would have to supply them with a `Custom data processor <https://docs.typo3.org/permalink/t3tsref:customdataprocessors>`_.
101+
102+
.. _usage-settings-typoscript:
103+
104+
Using settings in TypoScript
105+
============================
106+
107+
In both frontend TypoScript and backend TypoScript, also called TSconfig, the
108+
settings can be used with the
109+
`TypoScript constants syntax <https://docs.typo3.org/permalink/t3tsref:typoscript-syntax-using-constants>`_.
110+
111+
In the site package example we use constants to configure the path to the
112+
favicon and templates (both of type `string`):
113+
114+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript
115+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript
116+
117+
And in the footer menu we use a setting of type `int` to set the root folder in
118+
which the pages for the footer menu are found:
119+
120+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript
121+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript
122+
123+
It is also possible to use settings in TypoScript conditions:
124+
`Check if a setting/constant is set to a certain value <https://docs.typo3.org/permalink/t3tsref:condition-examples-constant>`_.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MySitePackage.footerMenuRoot:
2+
label: 'Footer menu root uid'
3+
description: 'The subpages of this page are displayed in the footer'
4+
category: MySitePackage.menus
5+
type: int
6+
default: 2

0 commit comments

Comments
 (0)