Skip to content

Commit 54abb8a

Browse files
committed
[FEATURE] TypoScript module renamed: Document for constants
Related: TYPO3-Documentation/Changelog-To-Doc#136 Releases: main, 12.4
1 parent e088dc3 commit 54abb8a

File tree

4 files changed

+61
-29
lines changed

4 files changed

+61
-29
lines changed
62.6 KB
Loading
51 KB
Loading

Documentation/UsingSetting/Constants.rst

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,30 @@
77
Constants
88
=========
99

10-
.. include:: /Images/AutomaticScreenshots/TemplatesModul/TemplatesConstants.rst.txt
10+
.. versionchanged:: 12.0
11+
The TypoScript management tools are now found in backend module
12+
:guilabel:`Site Management > TypoScript`. It was formerly found in
13+
"Page > Template".
14+
15+
.. figure:: /Images/ManualScreenshots/TypoScriptModule/ConstantEditor.png
16+
:alt: Screenshot of the TYPO3 Backend showing the constant editor
17+
18+
The :ref:`Constant Editor <constant-editor>` in the TYPO3 backend
1119

1220
Constants are values defined in the :guilabel:`Constants` field of a template. They
1321
follow the :ref:`syntax of ordinary TypoScript
1422
<t3coreapi:typoscript-syntax-syntax>` and are case sensitive! They are used to
1523
manage *in a single place* values, which are later used in *several places*.
1624

25+
.. seealso::
26+
Most constants can be edited in the :guilabel:`Template` module using the
27+
:guilabel:`Constant Editor`.
28+
29+
If you keep your constants in a site package extension you can also make
30+
them :ref:`available for the Constant Editor <typoscript-syntax-constant-editor>`.
31+
1732
.. index:: Constants; Definition
33+
.. _typoscript-syntax-constants-definition:
1834

1935
Defining constants
2036
==================
@@ -35,6 +51,7 @@ Constants do not support multiline values!
3551
You can use environment variables to provide instance specific values to your constants.
3652
Refer to :ref:`getEnv <getenv>` for further information.
3753

54+
.. _typoscript-syntax-constants-definition-example:
3855

3956
Example
4057
-------
@@ -49,11 +66,11 @@ expected location.
4966
5067
bgCol = red
5168
file {
52-
toplogo = fileadmin/logo.gif
69+
toplogo = fileadmin/logo.gif
5370
}
5471
topimg {
55-
width = 200
56-
file.pic2 = fileadmin/logo2.gif
72+
width = 200
73+
file.pic2 = fileadmin/logo2.gif
5774
}
5875
5976
The objects in the highlighted lines contain the reserved word "file" and the
@@ -78,55 +95,69 @@ one would perform any ordinary string replacement. Constants are used in the
7895
{$topimg.file.pic2}
7996
{$file.toplogo}
8097
81-
Only constants, which are actually defined in the :guilabel:`Constants` field, are
98+
Only constants, which are actually defined in the :guilabel:`Constants` field
99+
or an included :file:`constants.typoscript` file, are
82100
substituted.
83101

84-
Constants in included templates are also substituted, as the whole
85-
template is one large chunk of text.
102+
Constants from included TypoScript files are also substituted. All TypoScript
103+
constants are combined before the TypoScript Setup configuration is resolved.
86104

87105
A systematic naming scheme should be used for constants. As "paths" can be
88106
defined, it's also possible to structure constants and prefix them with a common
89107
path segment. This makes reading and finding of constants easier.
90108

109+
.. _typoscript-syntax-using-constants-example:
110+
91111
Example
92112
-------
93113

94114
.. code-block:: typoscript
115+
:caption: EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
95116
96117
page = PAGE
97118
page {
98-
typeNum = 0
99-
bodyTag = <body bgColor="{$bgCol}">
100-
10 = IMAGE
101-
10.file = {$file.toplogo}
119+
typeNum = 0
120+
bodyTag = <body class="{$tx_my_sitepackage.bgCol}">
121+
10 = IMAGE
122+
10.file = {$tx_my_sitepackage.file.toplogo}
102123
}
103124
104125
For the above example to work, the constants from the last example have to be
105-
defined in the constants field.
126+
defined in the constants field or a file called :file:`constants.typoscript`:
106127

107-
.. include:: /Images/AutomaticScreenshots/TemplatesModul/TemplatesSetup.rst.txt
128+
.. code-block:: typoscript
129+
:caption: EXT:my_sitepackage/Configuration/TypoScript/constants.typoscript
108130
109-
Constants in the setup code are substituted, marked in green. In the Object
110-
Browser, it's possible to show constants substituted and unsubstituted.
131+
tx_my_sitepackage {
132+
bgCol = bg-primary
133+
file.toplogo = EXT:my_sitepackage/Resources/Public/Images/Logo.png
134+
}
111135
112-
The "Display constants" function is not available if "Crop lines" is selected.
136+
.. figure:: /Images/ManualScreenshots/TypoScriptModule/ConstantAndSetupRecord.png
137+
:alt: Screenshot of the TypoScript record editor showing the Constants and Setup fields
113138

114-
.. note::
139+
The fields :guilabel:`Constants` and :guilabel:`Setup` in the TypoScript backend record
115140

116-
The TypoScript constants are evaluated in this order:
141+
You can use the sub module :guilabel:`Site Management > TypoScript > Active TypoScript`
142+
to display how constants are replaced. The constant key is displayed in red, the
143+
replacement in green:
117144

118-
#. :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']`
119-
via :php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants()`
120-
#. Site specific :ref:`settings from the site configuration <t3coreapi:sitehandling>`
121-
#. Constants from :sql:`sys_template` database records
145+
.. figure:: /Images/ManualScreenshots/TypoScriptModule/ConstantsInActiveTypoScript.png
146+
:alt: Screenshot of the Active TypoScript with constants substituted
122147

148+
.. versionchanged:: 12.0
149+
The TypoScript management tools are now found in backend module
150+
:guilabel:`Site Management > TypoScript`. It was formerly found in
151+
"Page > Template".
123152

124-
The constant editor
125-
===================
153+
The submodule :guilabel:`Active TypoScript` was renamed from
154+
"TypoScript Object Browser".
126155

127-
Most constants can be edited in the :guilabel:`Template` module using the :guilabel:`constant editor`.
128-
If you keep your constants in a sitepackage extension you can also make them :ref:`available for the
129-
constant editor <typoscript-syntax-constant-editor>`.
156+
.. note::
130157

131-
.. include:: /Images/AutomaticScreenshots/TemplatesModul/TemplatesConstantEditor.rst.txt
158+
The TypoScript constants are evaluated in this order:
132159

160+
#. :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']`
161+
via :php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants()`
162+
#. Site specific :ref:`settings from the site configuration <t3coreapi:sitehandling>`
163+
#. Constants from :sql:`sys_template` database records

Documentation/UsingSetting/TheConstantEditor.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ The constant editor
88

99
.. versionchanged:: 12.0
1010
The TypoScript management tools are now found in backend module
11-
:guilabel:`Site Management > TypoScript`
11+
:guilabel:`Site Management > TypoScript`. It was formerly found in
12+
"Page > Template".
1213

1314
It's possible to add comments in TypoScript. Comments are always ignored by the
1415
parser when the TypoScript is processed. But the backend module

0 commit comments

Comments
 (0)