Extend TCA
Content Blocks generates a lot of boilerplate TCA (Table Configuration Array) for you. Usually you don't need to write own TCA, but in some cases, where you want to override the TCA from Content Blocks, you can do it with own TCA overrides.
How to override Content Blocks TCA
Note
First make sure, you've added Content Blocks as a dependency in your extension.
Finding the correct identifier
The identifier to use in TCA depends on whether the Content Block uses
prefix
or not. If this feature is enabled, your field identifiers
are prefixed with the vendor and content block name. Example:
my-
and field identifier header
result
in myvendor_
. See how dashes are removed and the two
parts are glued together with an underscore. The same goes for the table name of
Collection
fields. myvendor_
is also the resulting
type
, if not set explicitly. This can be used to override the TCA
types
array. Otherwise, the field and table identifiers defined in the
YAML config are identical to the TCA one.
Fields in tt_content
It works exactly like overriding core TCA.
Example:
$GLOBALS['TCA']['tt_content']['columns']['myvendor_mycontentblock_header']['config']['some_option'] = 'some_value';
$GLOBALS['TCA']['tt_content']['types']['myvendor_mycontentblock']['some_option'] = 'some_value';
Fields in custom tables / record types
As soon as you create a Collection field,
Content Blocks creates a new custom table. Therefore you need to change the key
to the table's name. Extend the TCA in Configuration/
.
For record types you already defined a table
, so use this as the key.
Example:
$GLOBALS['TCA']['myvendor_mycontentblock_mycollection']['columns']['your_field']['config']['some_option'] = 'some_value';
$GLOBALS['TCA']['my_record_type_table']['columns']['your_field']['config']['some_option'] = 'some_value';