Skip to content

Commit 0cb3594

Browse files
authored
[TASK] Improve descriptions on how to provide TypoScript (#1438)
Releases: main, 13.4
1 parent 77c7edc commit 0cb3594

File tree

5 files changed

+184
-66
lines changed

5 files changed

+184
-66
lines changed

Documentation/UsingSetting/AddTypoScriptWithExtensions.rst

Lines changed: 169 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
:navigation-title: TypoScript in Extensions
2+
13
.. include:: /Includes.rst.txt
24
.. index:: TypoScript in extensions
35
.. _extdev-add-typoscript:
46

5-
================================
6-
Add TypoScript in your extension
7-
================================
7+
================================================
8+
Provide frontend TypoScript in a TYPO3 extension
9+
================================================
810

911
.. versionchanged:: 13.1
1012
TypoScript on a per-site basis can now be included via
@@ -18,8 +20,8 @@ Add TypoScript in your extension
1820
.. index:: TypoScript in extensions; File locations
1921
.. _extdev-add-typoscript-extension:
2022

21-
Create TypoScript files in your extension
22-
=========================================
23+
Provide TypoScript in your extension or site package
24+
====================================================
2325

2426
TypoScript files **must** have the ending :file:`.typoscript`.
2527

@@ -28,10 +30,11 @@ extension. Read more about how to
2830
:ref:`provide the TypoScript as set for TYPO3 v13 and above <extdev-add-typoscript-sets>`
2931
and :ref:`how to provide TypoScript for both TYPO3 v13 and v12 <extdev-add-typoscript-sets-v12>`.
3032

31-
* :file:`constants.typoscript` contains the constants
32-
* :file:`setup.typoscript` contains the TypoScript setup
33+
* :file:`constants.typoscript` contains the frontend TypoScript constants
34+
* :file:`setup.typoscript` contains the frontend TypoScript
3335

3436
.. _extdev-add-typoscript-sets:
37+
.. _extdev-add-typoscript-sets-typoscript:
3538

3639
TypoScript provided as site set (only TYPO3 v13.1 and above)
3740
============================================================
@@ -41,10 +44,6 @@ The file structure of the extension could, for example look like this:
4144
.. directory-tree::
4245
:show-file-icons: true
4346

44-
* Classes
45-
46-
* ...
47-
4847
* Configuration
4948

5049
* Sets
@@ -93,103 +92,209 @@ The sub set for an optional feature
9392
:language: yaml
9493
:caption: EXT:my_extension/Configuration/Sets/MyExtensionWithACoolFeature/config.yaml
9594

96-
.. _extdev-add-typoscript-sets-typoscript:
9795

98-
TypoScript files provided by the sets
99-
-------------------------------------
96+
.. _extdev-add-typoscript-sets-override:
97+
98+
Overriding the TypoScript
99+
-------------------------
100100

101-
The TypoScript placed in the same folder like the set, contains your
102-
configurations.
101+
The TypoScript provided in the site set will be loaded exactly once and respect
102+
the dependencies defined in the site set configuration. Therefore if you
103+
have to override the frontend TypoScript of another site set your site set
104+
should depend on the other site set:
103105

106+
.. code-block:: yaml
107+
:caption: packages/my_site_package/Configuration/Sets/MySitePackage/config.yaml
108+
109+
name: my-vendor/my-site-package
110+
label: My Set
111+
dependencies:
112+
- my-vendor/my-other-set
113+
- some-vendor/some-extension
114+
115+
Your extension can then safely override frontend TypoScript of the `some_extension`,
116+
for example:
117+
118+
.. code-block:: typoscript
119+
:caption: packages/my_site_package/Configuration/Sets/MySitePackage/setup.typoscript
120+
121+
plugin.some_extension_pi1.settings.someSetting = Special setting
122+
123+
.. _extdev-add-typoscript-sets-v12-static_includes:
124+
.. _extdev-static-includes:
104125
.. _extdev-add-typoscript-sets-v12:
105126

106-
TypoScript provided by extensions supporting TYPO3 v12.4 and v13
107-
================================================================
127+
Supporting both site sets and TypoScript records
128+
================================================
108129

109-
When an extension provides TypoScript and should be compatible with both
110-
TYPO3 v12.4 and v13, you can provide site sets but still support including
111-
the TypoScript in the :sql:`sys_template` record via `static_file_include`'s.
130+
.. versionchanged:: 13.1
131+
With TYPO3 13.1
132+
`site sets as TypoScript provider <https://docs.typo3.org/permalink/t3coreapi:site-sets-typoscript>`_
133+
where introduced. Existing extensions **should** support site sets as well as
134+
TypoScript records for backward compatibility reasons.
135+
136+
.. warning::
137+
For historic reasons you might still see filenames like :file:`setup.ts` and
138+
:file:`setup.txt`. These files **cannot** be included with the
139+
:ref:`@import <t3tsref:typoscript-syntax-import>` syntax. All frontend
140+
TypoScript files **must** end on `.typoscript`.
141+
142+
.. _extension-configuration-typoscript-set-record-one:
143+
144+
One TypoScript include set
145+
--------------------------
112146

113-
The files in the sets are the same as in the
114-
:ref:`example for TYPO3 v13 only <extdev-add-typoscript-sets>`.
147+
If your extension supported one static file include you should provide the same
148+
files in your main site set as well:
115149

116-
The extended file structure of the extension could, for example look like this:
150+
.. code-block:: php
151+
:caption: EXT:my_extension/Configuration/TCA/Overrides/sys_template.php (before and after)
152+
153+
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
154+
'my_extension',
155+
'Configuration/TypoScript/',
156+
'Examples TypoScript'
157+
);
158+
159+
In your main site set provide the same files that where provided as includes
160+
by :php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile`
161+
until now:
117162

118163
.. directory-tree::
164+
:level: 3
119165
:show-file-icons: true
120166

121-
* Classes
167+
* packages/my_extension/Configuration/
122168

123-
* ...
169+
* Sets
124170

125-
* Configuration
171+
* MySet
126172

127-
* Sets
173+
* config.yaml
174+
* constants.typoscript
175+
* setup.typoscript
128176

129-
* MyExtension
130177

131-
* :ref:`config.yaml <extdev-add-typoscript-sets-main>`
132-
* :ref:`constants.typoscript <extdev-add-typoscript-sets-typoscript>`
133-
* :ref:`setup.typoscript <extdev-add-typoscript-sets-typoscript>`
178+
* TypoScript
134179

135-
* MyExtensionWithACoolFeature
180+
* constants.typoscript
181+
* setup.typoscript
136182

137-
* :ref:`config.yaml <extdev-add-typoscript-sets-feature>`
138-
* :ref:`setup.typoscript <extdev-add-typoscript-sets-typoscript>`
183+
.. code-block:: typoscript
184+
:caption: packages/my_extension/Configuration/Sets/MySet/constants.typoscript
139185
140-
* TCA
186+
@import 'EXT:my_extension/Configuration/TypoScript/setup.typoscript'
141187
142-
* Overrides
188+
.. code-block:: typoscript
189+
:caption: packages/my_extension/Configuration/Sets/MySet/setup.typoscript
143190
144-
sys_template.php
191+
@import 'EXT:my_extension/Configuration/TypoScript/setup.typoscript'
145192
193+
.. _extension-configuration-typoscript-set-record-multiple:
146194

147-
* Resources
195+
Multiple TypoScript include sets
196+
--------------------------------
148197

149-
* ...
198+
If there should be more then one set of TypoScript templates that may be
199+
included, they were usually stored in sub folders of
200+
:path:`Configuration/TypoScript` until now.
150201

151-
* composer.json
152-
* ...
202+
When introducing site sets usually one site set per TypoScript record include
203+
set is needed:
153204

205+
.. directory-tree::
206+
:level: 3
207+
:show-file-icons: true
154208

155-
.. _extdev-add-typoscript-sets-v12-static_includes:
156-
.. _extdev-static-includes:
209+
* packages/my_extension/Configuration
210+
211+
* TypoScript
212+
213+
* SpecialFeature1
214+
215+
* constants.typoscript
216+
* setup.typoscript
157217

158-
Only when supporting TYPO3 v12.4: Make TypoScript available for static includes
159-
-------------------------------------------------------------------
218+
* SpecialFeature2
160219

161-
Make TypoScript available for static includes (only needed if your extensions aims to support TYPO3 v12.4):
220+
* setup.typoscript
162221

163-
.. literalinclude:: _Sets/_TcaOverridesSystemplateV12.php
164-
:language: php
165-
:caption: EXT:my_extension/Configuration/TCA/Overrides/sys_template.php
222+
* constants.typoscript
223+
* setup.typoscript
166224

167-
If you include the TypoScript this way, it will not be automatically loaded.
168-
You MUST load it by adding the static include in the :guilabel:`Web > Template`
169-
module in the backend, see :ref:`static-includes`. This has the advantage of
170-
better configurability.
225+
* Sets
171226

172-
This will load your constants and your setup once the template is
173-
included statically.
227+
* MyMainSet
228+
229+
* config.yaml
230+
* constants.typoscript
231+
* setup.typoscript
232+
233+
* MySpecialFeature1Set
234+
235+
* config.yaml
236+
* constants.typoscript
237+
* setup.typoscript
238+
239+
* MySpecialFeature2Set
240+
241+
* config.yaml
242+
* setup.typoscript
243+
244+
For backward compability reasons :php:`ExtensionManagementUtility::addStaticFile`
245+
still needs to be called for each folder that should be available in the TypoScript
246+
template record:
247+
248+
.. code-block:: php
249+
:caption: EXT:my_extension/Configuration/TCA/Overrides/sys_template.php
250+
251+
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
252+
'my_extension',
253+
'Configuration/TypoScript/',
254+
'My Extension - Main TypoScript'
255+
);
256+
257+
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
258+
'my_extension',
259+
'Configuration/TypoScript/Example1/',
260+
'My Extension - Additional example 1'
261+
);
262+
263+
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
264+
'my_extension',
265+
'Configuration/TypoScript/SpecialFeature2/',
266+
'My Extension - Some special feature'
267+
);
268+
269+
Each site set then provides the TypoScript files the according location by
270+
importing it, for example:
271+
272+
.. code-block:: typoscript
273+
:caption: packages/my_extension/Configuration/Sets/MySet/setup.typoscript
274+
275+
@import 'EXT:my_extension/Configuration/TypoScript/MySpecialFeature2Set/setup.typoscript'
174276
175277
.. index:: TypoScript in extensions; Load always
176278
.. _extdev-always-load:
177279

178280
Make TypoScript available (always load)
179281
=======================================
180282

181-
Only do this, if your TypoScript must really be always loaded in your site.
182-
If this is not the case, use the method described in the previous section
183-
:ref:`extdev-add-typoscript-sets`.
283+
284+
Use :php:`ExtensionManagementUtility::addTypoScript` if the frontend
285+
TypoScript **must** be available in backend modules without page context,
286+
for example to :ref:`register the YAML of the EXT:form system extension
287+
for the backend <typo3/cms-form:concepts-configuration-yamlregistration-backend>`.
184288

185289
.. literalinclude:: _Sets/_ext_localconf.php
186-
:language: php
187290
:caption: EXT:my_extension/ext_localconf.php
188291

189-
It is also possible to put your TypoScript in a file called
190-
:ref:`ext_typoscript_setup.typoscript <t3coreapi:ext_typoscript_setup_typoscript>`
191-
or :ref:`ext_typoscript_constants.typoscript <t3coreapi:ext_typoscript_constants_typoscript>`
192-
(for constants).
292+
.. warning::
293+
While the content from the files
294+
`ext_typoscript_setup.typoscript <https://docs.typo3.org/permalink/t3coreapi:ext_typoscript_setup_typoscript>`_
295+
and `ext_typoscript_constants.typoscript <https://docs.typo3.org/permalink/t3coreapi:ext_typoscript_constants_typoscript>`_
296+
is loaded by default in sites based on **TypoScript records** it is not
297+
loaded in sites depending on **site sets as TypoScript providers**.
193298

194299

195300
More information

Documentation/UsingSetting/Entering.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
:navigation-title: Backend Module
2+
23
.. include:: /Includes.rst.txt
34
.. index:: TypoScript; TypoScript backend module
45
.. _typoscript_module:

Documentation/UsingSetting/Index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
:navigation-title: Usage
12
.. include:: /Includes.rst.txt
23
.. index:: TypoScript; Using and setting
34
.. _using-and-setting:
45

6+
============================
57
Using and setting TypoScript
68
============================
79

@@ -19,8 +21,8 @@ The TypoScript template configuration can be viewed and edited in the
1921
:titlesonly:
2022

2123
SiteTypoScriptProvider
22-
Entering
2324
AddTypoScriptWithExtensions
25+
Entering
2426
AccessTypoScriptWithExtensions
2527
Constants
2628
Register

Documentation/UsingSetting/SiteTypoScriptProvider.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:navigation-title: TypoScript in Sites
2+
13
.. include:: /Includes.rst.txt
24
.. _typoscript-site-sets:
35

Documentation/UsingSetting/_Sets/_ext_localconf.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@
77
ExtensionManagementUtility::addTypoScript(
88
'my_extension',
99
'setup',
10-
"@import 'EXT:my_extension/Configuration/TypoScript/setup.typoscript'",
10+
'
11+
module.tx_form {
12+
settings {
13+
yamlConfigurations {
14+
100 = EXT:my_site_package/Configuration/Form/CustomFormSetup.yaml
15+
}
16+
}
17+
}
18+
',
1119
);

0 commit comments

Comments
 (0)