Skip to content

Commit 41279ea

Browse files
[TASK] Overhaul Extension Development Howto Extend TCA (#6255)
* [TASK] Overhaul Extension Development Howto Extend TCA Releases: main, Backport 13.4 * [TASK] Overhaul Extension Development Howto Extend TCA Releases: main, Backport 13.4
1 parent 6c38196 commit 41279ea

File tree

8 files changed

+98
-106
lines changed

8 files changed

+98
-106
lines changed

Documentation/ApiOverview/Fal/Administration/Storages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ File storages
77
=============
88

99
:ref:`File storages <fal-architecture-components-storage>` can be administered
10-
through the :guilabel:`Content > List` module. They have a few properties which
10+
through the :guilabel:`Content > Records` module. They have a few properties which
1111
deserve further explanation.
1212

1313
.. include:: /Images/AutomaticScreenshots/Fal/AdministrationFileStorageAccessTab.rst.txt

Documentation/ExtensionArchitecture/HowTo/ExtendingTca/Examples/Index.rst

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Customization Examples
66
======================
77

8-
Many extracts can be found throughout the manual, but this section
9-
provides more complete examples.
8+
There are many customization examples in the documentation, but this section
9+
provides the most complete examples.
1010

1111

1212
.. index::
@@ -18,7 +18,7 @@ Example 1: Extending the fe\_users table
1818
========================================
1919

2020
The "examples" extension adds two fields to the "fe\_users" table.
21-
Here's the complete code, taken from file
21+
Here is the complete code, taken from file
2222
:file:`Configuration/TCA/Overrides/fe_users.php`:
2323

2424
.. code-block:: php
@@ -70,23 +70,22 @@ Read :ref:`why the check for the TYPO3 constant is necessary <globals-constants-
7070

7171
.. note::
7272

73-
The second example :php:`tx_examples_special` only works when the
74-
:php:`renderType` has been registered implemented and then registered in
75-
the ext_localconf.php. Please refer to the the following chapter of the
76-
TCA reference on how to implement it: :ref:`t3tca:columns-user`.
73+
The second example, :php:`tx_examples_special`, only works when
74+
:php:`renderType` has been registered, implemented, and registered in
75+
ext_localconf.php. Please refer to :ref:`t3tca:columns-user`.
7776

7877

79-
In this example the first method call adds fields using
80-
:php:`ExtensionManagementUtility::addTCAcolumns()`. This ensures that the fields
81-
are registered in :php:`$GLOBALS['TCA']`. Parameters:
78+
The first method call adds fields using
79+
:php:`ExtensionManagementUtility::addTCAcolumns()`. This registers the fields
80+
in :php:`$GLOBALS['TCA']`. The parameters are:
8281

8382
1. Name of the table to which the fields should be added.
84-
2. An array of the fields to be added. Each field is represented in the
83+
2. An array of the fields to be added. Each field is in
8584
:ref:`TCA syntax for columns <t3tca:columns>`.
8685

87-
Since the fields are only registered but not used anywhere, the fields are
88-
afterwards added to the "types" definition of the :sql:`fe_users` table by
89-
calling :php:`ExtensionManagementUtility::addToAllTCAtypes()`. Parameters:
86+
At this point the fields have been registered but not used anywhere, so they need to be added
87+
to the "types" definition of the :sql:`fe_users` table by
88+
calling :php:`ExtensionManagementUtility::addToAllTCAtypes()`. The parameters are:
9089

9190
1. Name of the table to which the fields should be added.
9291
2. Comma-separated string of fields, the same syntax used in the
@@ -97,19 +96,19 @@ calling :php:`ExtensionManagementUtility::addToAllTCAtypes()`. Parameters:
9796
to an existing field (:php:`after:myfield`) or
9897
palette (:php:`after:palette:mypalette`).
9998

100-
So you could do this:
99+
Example code:
101100

102101
.. literalinclude:: _fe_users.php
103102
:language: php
104103
:caption: EXT:some_extension/Configuration/TCA/Overrides/fe_users.php
105104

106-
If the fourth parameter (position) is omitted or the specified field is not found,
107-
new fields are added at the bottom of the form. If the table uses tabs,
108-
new fields are added at the bottom of the :guilabel:`Extended` tab. This tab
105+
If the fourth parameter is omitted or the field is not found,
106+
new fields are added to the bottom of the form. If the table uses tabs,
107+
new fields are added to the bottom of the :guilabel:`Extended` tab. This tab
109108
is created automatically if it does not exist.
110109

111-
These method calls do not create the corresponding fields in the database. The new
112-
fields must also be defined in the :file:`ext_tables.sql` file of the extension:
110+
These method calls do not create fields in the database. To do
111+
this, the new fields must be defined in the :file:`ext_tables.sql` file of the extension:
113112

114113
.. code-block:: sql
115114
:caption: EXT:some_extension/ext_tables.sql
@@ -128,12 +127,12 @@ fields must also be defined in the :file:`ext_tables.sql` file of the extension:
128127
table already exists.
129128

130129

131-
The following screen shot shows the placement of the two
130+
The following screenshot shows the position of the two
132131
new fields when editing a "fe\_users" record:
133132

134133
.. include:: /Images/AutomaticScreenshots/ExtendingTca/ExtendingTcaFeUsers.rst.txt
135134

136-
The next example shows how to place a field more precisely.
135+
The next example shows how to position a field more precisely.
137136

138137

139138
.. index::
@@ -144,7 +143,7 @@ The next example shows how to place a field more precisely.
144143
Example 2: Extending the tt\_content Table
145144
==========================================
146145

147-
In the second example, we will add a "No print" field to all content
146+
In this second example, we will add a "No print" field to all content
148147
element types. First of all, we add its SQL definition in
149148
:file:`ext_tables.sql`:
150149

@@ -186,16 +185,14 @@ Then we add it to the :php:`$GLOBALS['TCA']` in :file:`Configuration/TCA/Overrid
186185
'before:editlock'
187186
);
188187
189-
The code is mostly the same as in the first example, but the last method call
190-
is different and requires an explanation. The tables :code:`pages` and
191-
:code:`tt_content` use :ref:`palettes <t3tca:palettes>` extensively. This increases
192-
flexibility.
193-
194-
Therefore we call :code:`ExtensionManagementUtility::addFieldsToPalette()`
188+
The code is similar to the first example, but the last method call
189+
is different. The tables :code:`pages` and
190+
:code:`tt_content` use :ref:`palettes <t3tca:palettes>` extensively. Therefore,
191+
we call :code:`ExtensionManagementUtility::addFieldsToPalette()`
195192
instead of :code:`ExtensionManagementUtility::addToAllTCAtypes()`.
196-
We need to specify the palette's key as the second argument (:code:`access`).
197-
Precise placement of the new field is achieved with the fourth parameter
198-
(:code:`before:editlock`). This will place the "no print" field right before the
193+
We need to specify the palette key as the second argument (:code:`access`).
194+
The new field is positioned by the fourth parameter
195+
(:code:`before:editlock`). This will position the "no print" field before the
199196
:guilabel:`Restrict editing by non-Admins` field, instead of putting it in the
200197
:guilabel:`Extended` tab.
201198

@@ -205,12 +202,11 @@ The result is the following:
205202

206203
.. note::
207204

208-
Obviously this new field will not magically exclude a content element
209-
from being printed. For it to have any effect, it must be used during
210-
the rendering by modifying the TypoScript used to render the
211-
:sql:`tt_content` table. Although this is outside the scope of this
205+
Obviously this new field doesn't do anything yet. For it to do its job of
206+
excluding a content element from being printed, it must modify the TypoScript
207+
used to render the :sql:`tt_content` table. Although this is outside the scope of this
212208
manual, here is an example of what you could do, for the sake of
213-
showing a complete process.
209+
showing the complete process.
214210

215211
Assuming you are using "fluid\_styled\_content" (which is installed by
216212
default), you could add the following TypoScript to your template:
@@ -225,6 +221,6 @@ The result is the following:
225221
be to declare the appropriate selector in the print-media CSS file so
226222
that "noprint" elements don't get displayed.
227223

228-
This is just an example of how the effect of the "No print" checkbox
229-
can be ultimately implemented. It is meant to show that just adding
224+
This is just an example of how the "No print" checkbox
225+
can be implemented. It is meant to show that just adding
230226
the field to the :php:`$GLOBALS['TCA']` is not enough.

Documentation/ExtensionArchitecture/HowTo/ExtendingTca/Index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:navigation-title: TCA extension
1+
:navigation-title: Extend TCA
22

33
.. include:: /Includes.rst.txt
44
.. index::

Documentation/ExtensionArchitecture/HowTo/ExtendingTca/StoringChanges/Index.rst

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33

44
.. _storing-changes:
55

6-
===================
7-
Storing the changes
8-
===================
6+
=====================
7+
Storing modifications
8+
=====================
99

10-
There are various ways to store changes to :php:`$GLOBALS['TCA']`. They
11-
depend - partly - on what you are trying to achieve and - a lot -
12-
on the version of TYPO3 CMS which you are targeting. The TCA can only be
13-
changed from within an extension.
10+
There are various ways to store modifications to :php:`$GLOBALS['TCA']`. They
11+
depend on what you are trying to achieve and the version of TYPO3 CMS you are
12+
targeting. The TCA can only be modified from inside an extension.
1413

1514
.. versionchanged:: 14.0
16-
There are two changes for :php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin()`.
15+
There are two changes to :php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin()`.
1716
The second argument :php:`$type` and the third argument :php:`$extensionKey`
1817
have been dropped.
1918

@@ -22,28 +21,26 @@ changed from within an extension.
2221
Storing in extensions
2322
=====================
2423

25-
The advantage of putting your changes inside an extension is that they
26-
are nicely packaged in a self-contained entity which can be easily
27-
deployed on multiple servers.
24+
The advantage of putting modifications inside extensions is that the modifications
25+
are packaged in a self-contained entity that can be easily deployed.
2826

29-
The drawback is that the extension loading order must be finely controlled. However, **in
30-
case you are modifying Core TCA, you usually don't have to worry about that**. Since
31-
custom extensions are always loaded *after* the Core's TCA, changes from custom extensions
32-
will usually take effect without any special measures.
27+
The drawback is that extension loading order must be finely controlled.
28+
**If you are modifying Core TCA, you usually don't have to worry about
29+
loading order**. Custom extensions are always loaded *after* the Core TCA, so
30+
modifications from custom extensions should always take effect.
3331

34-
In case your extension modifies another extension, you actively need to make
35-
sure your extension is loaded *after* the extension you are modifying. This can
36-
be achieved by registering that other extension as a dependency (or suggestion)
32+
If your extension modifies another extension, make
33+
sure your extension is loaded *after* the extension you are modifying. You can
34+
do this by registering the other extension as a dependency (or suggestion)
3735
of yours. See the :ref:`description of constraints in Core APIs <extension-declaration>`.
3836

39-
The loading order also matters if you have multiple extensions overriding the
40-
same field, probably even contradicting each other.
37+
Loading order also matters if you have multiple extensions overriding the
38+
same field or contradicting each other.
4139

42-
Files within :file:`Configuration/TCA/` files are loaded
43-
within a dedicated scope. This means that variables defined in those files
44-
cannot leak into the following files.
40+
Files in :file:`Configuration/TCA/` are loaded inside a dedicated scope. This means
41+
that variables defined in those files cannot leak into other files.
4542

46-
For more information about an extension's structure, please refer to the
43+
For more information about extension structure, please refer to the
4744
:ref:`extension architecture <extension-architecture>` chapter.
4845

4946
.. index::
@@ -55,39 +52,39 @@ For more information about an extension's structure, please refer to the
5552
Storing in the :file:`Overrides/` folder
5653
----------------------------------------
5754

58-
Changes to :php:`$GLOBALS['TCA']`
59-
must be stored inside a folder called :file:`Configuration/TCA/Overrides/`.
60-
For clarity files should be named along the pattern
61-
:file:`<tablename>.php`.
55+
Modifications to :php:`$GLOBALS['TCA']`
56+
must be stored in :file:`Configuration/TCA/Overrides/`. For clarity, files should
57+
be named :file:`<tablename>.php`.
6258

63-
Thus, if you want to customize the TCA of :sql:`tx_foo_domain_model_bar`,
64-
you need to create the file :file:`Configuration/TCA/Overrides/tx_foo_domain_model_bar.php`.
59+
For example, if you want to modify the TCA of :sql:`tx_foo_domain_model_bar`,
60+
create file :file:`Configuration/TCA/Overrides/tx_foo_domain_model_bar.php`.
6561

66-
The advantage of this method is that all such changes are incorporated into
67-
:php:`$GLOBALS['TCA']` **before** it is cached. This is thus far more efficient.
62+
The advantage of this method is that changes will be incorporated into
63+
:php:`$GLOBALS['TCA']` **before** it is cached (which is very efficient).
6864

6965
.. note::
70-
All files within :file:`Configuration/TCA/Overrides/` will be loaded, you are not forced
71-
to have a single file for table "tt\_content" for instance. When dealing with custom
72-
content elements this file can get 1000+ lines very quickly and maintainability can get
73-
hard quickly as well.
74-
75-
Also names don't matter in that folder, at least not to TYPO3. They only might influence
76-
loading order. Proper naming is only relevant for the real definition of tables one
66+
All files in :file:`Configuration/TCA/Overrides/` will be loaded, so you can
67+
divide up long files such as for table "tt\_content" rather than
68+
having one long file. Otherwise, if you have custom
69+
content elements this file can reach 1000+ lines very quickly, affecting
70+
maintainability.
71+
72+
Also, names don't matter in this folder, at least not to TYPO3. They only influence
73+
loading order. Proper naming is only relevant for the table definitions one
7774
folder up in :file:`Configuration/TCA/`
7875

7976
.. attention::
80-
Be aware that you cannot extend the TCA of extensions if it was configured within
81-
its :file:`ext_tables.php` file, usually containing the "ctrl" section
82-
referencing a "dynamicConfigFile". Please ask the extension author to switch
77+
You cannot extend the TCA of an extension if the modifications
78+
are in its :file:`ext_tables.php` file (usually a "ctrl" section
79+
referencing a "dynamicConfigFile"). Please ask the extension author to switch
8380
to the :file:`Configuration/TCA/<tablename>.php` setup.
8481

8582
.. attention::
86-
Only TCA-related changes should go into :file:`Configuration/TCA/Overrides`
87-
files. Some API calls may be okay as long as they also manipulate only
88-
:php:`$GLOBALS['TCA']`. For example, it is fine to register a plugin with
83+
Only TCA-related modifications should go in :file:`Configuration/TCA/Overrides`
84+
files. Some API calls may be okay if all they do is manipulate
85+
:php:`$GLOBALS['TCA']`. For example, a plugin can be registered with
8986
:php:`\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin()` in
90-
:file:`Configuration/TCA/Overrides/tt_content.php` because that API call only
87+
:file:`Configuration/TCA/Overrides/tt_content.php` because the API call only
9188
modifies :php:`$GLOBALS['TCA']` for table :sql:`tt_content`.
9289

9390
.. index::triple:PSR-14 event; TCA; AfterTcaCompilationEvent;
@@ -96,6 +93,6 @@ The advantage of this method is that all such changes are incorporated into
9693
Changing the TCA "on the fly"
9794
=============================
9895

99-
It is also possible to perform some special manipulations on
100-
:php:`$GLOBALS['TCA']` right before it is stored into cache, thanks to the
96+
It is possible to manipulate
97+
:php:`$GLOBALS['TCA']` just before it is stored in the cache. Use the
10198
:ref:`PSR-14 event <EventDispatcher>` :ref:`AfterTcaCompilationEvent <AfterTcaCompilationEvent>`.

Documentation/ExtensionArchitecture/HowTo/ExtendingTca/Verifying/Index.rst

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@
77
=================
88
Verifying the TCA
99
=================
10-
You may find it necessary – at some point – to verify the full
11-
structure of the :php:`$GLOBALS['TCA']` in your TYPO3 installation.
12-
The :guilabel:`System > Configuration` module makes it possible to have an overview of the
13-
complete :php:`$GLOBALS['TCA']`, with all customizations taken into account.
10+
At some point it may be necessary to check the overall structure of
11+
:php:`$GLOBALS['TCA']` in your TYPO3 installation.
12+
The :guilabel:`System > Configuration` module gives you an overview of the
13+
complete :php:`$GLOBALS['TCA']`, with all modifications taken into account.
1414

15-
.. note:: The :guilabel:`Configuration` module is part of the lowlevel system extension. In Composer mode
16-
you can install it with:
15+
.. note::
16+
The :guilabel:`Configuration` module is part of the lowlevel system extension. In Composer mode you can install it with:
1717

1818
.. code-block:: shell
1919
2020
composer req typo3/cms-lowlevel
2121
2222
.. include:: /Images/AutomaticScreenshots/ExtendingTca/VerifyingTca.rst.txt
2323

24-
If you cannot find your new field, it probably means that you have
25-
made some mistake.
24+
If you can't find your new field it probably means that you have
25+
made a mistake somewhere.
2626

27-
This view is also useful when trying to find out where to insert a new
28-
field, to explore the combination of types and palettes that may be
29-
used for the table that we want to extend.
27+
The :guilabel:`System > Configuration` module overview is generally useful when you are extending TCA to find out where to insert
28+
fields and which types and palettes are used for a particular table.

Documentation/ExtensionArchitecture/HowTo/Index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
:navigation-title: Howto
1+
:navigation-title: How-to
22

33
.. include:: /Includes.rst.txt
44
.. index::
55
Extension development; How to
66
.. _extension-howto:
77

8-
=====================================
9-
Howto guides for extension developers
10-
=====================================
8+
======================================
9+
How-to guides for extension developers
10+
======================================
1111

1212
Helps you kickstart your own extension or site package. Explains how
1313
to publish an extension. Contains howto for different situations

Documentation/ExtensionArchitecture/Index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Extension development
3939
Learn about tools to create a new extension or add
4040
functionality to an existing extension.
4141

42-
.. card:: :ref:`Howto <extension-howto>`
42+
.. card:: :ref:`How-tos <extension-howto>`
4343

4444
Kickstart your own extension or sitepackage. Explains how
4545
to publish an extension. Contains howtos for creating a frontend plugin,

Documentation/ExtensionArchitecture/Tutorials/Tea/Model.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Now the edit form for tea records will look like this:
167167

168168
The complete input form for a tea record.
169169

170-
The list of teas in the module :guilabel:`Content -> List` looks like this:
170+
The list of teas in the module :guilabel:`Content > Records` looks like this:
171171

172172

173173
.. figure:: /Images/ManualScreenshots/ExtensionArchitecture/Tutorials/Tea/TeaList.png

0 commit comments

Comments
 (0)