Skip to content

Commit 4de9b04

Browse files
sarahmccarthy123froemken
authored andcommitted
[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 4495731 commit 4de9b04

File tree

6 files changed

+96
-103
lines changed

6 files changed

+96
-103
lines changed

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 & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,47 @@
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

1615
.. _storing-changes-extension:
1716

1817
Storing in extensions
1918
=====================
2019

21-
The advantage of putting your changes inside an extension is that they
22-
are nicely packaged in a self-contained entity which can be easily
23-
deployed on multiple servers.
20+
The advantage of putting modifications inside extensions is that the modifications
21+
are packaged in a self-contained entity that can be easily deployed.
2422

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

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

36-
Loading order also matters if you have multiple extensions overriding the same field,
37-
probably even contradicting each other.
34+
Loading order also matters if you have multiple extensions overriding the
35+
same field or contradicting each other.
3836

3937
.. versionadded:: 12.0
40-
Files within :file:`Configuration/TCA/` files are loaded within a dedicated scope.
41-
This means that variables defined in those files can't leak into the following files.
38+
Files in :file:`Configuration/TCA/` are loaded inside a dedicated scope. This means
39+
that variables defined in those files cannot leak into other files.
4240

4341
.. note::
4442
In TYPO3 v11 and below, variables declared in these files were in a shared scope,
4543
with the risk of a leakage to the following files. The use of :php:`call_user_func`
4644
wrap was a common workaround.
4745

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

5149
.. index::
@@ -57,39 +55,39 @@ For more information about an extension's structure, please refer to the
5755
Storing in the :file:`Overrides/` folder
5856
----------------------------------------
5957

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

65-
Thus, if you want to customize the TCA of :sql:`tx_foo_domain_model_bar`,
66-
you need to create the file :file:`Configuration/TCA/Overrides/tx_foo_domain_model_bar.php`.
62+
For example, if you want to modify the TCA of :sql:`tx_foo_domain_model_bar`,
63+
create file :file:`Configuration/TCA/Overrides/tx_foo_domain_model_bar.php`.
6764

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

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

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

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

9593
.. index::triple:PSR-14 event; TCA; AfterTcaCompilationEvent;
@@ -98,6 +96,6 @@ The advantage of this method is that all such changes are incorporated into
9896
Changing the TCA "on the fly"
9997
=============================
10098

101-
It is also possible to perform some special manipulations on
102-
:php:`$GLOBALS['TCA']` right before it is stored into cache, thanks to the
99+
It is possible to manipulate
100+
:php:`$GLOBALS['TCA']` just before it is stored in the cache. Use the
103101
: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,

0 commit comments

Comments
 (0)