diff --git a/Documentation/PageTsconfig/TcaDefaults.rst b/Documentation/PageTsconfig/TcaDefaults.rst index 59d6c1b7..7585dd97 100644 --- a/Documentation/PageTsconfig/TcaDefaults.rst +++ b/Documentation/PageTsconfig/TcaDefaults.rst @@ -8,26 +8,38 @@ TCAdefaults =========== -This allows to set or override the `default` values of `TCA` fields that is available -for various TCA types, for instance for :ref:`type=input `. +.. versionadded:: 14.0 + The :typoscript:`TCAdefaults` configuration has been extended to support + type-specific syntax similar to `TCEFORM `_, + enabling different default values based on the record type. -The full path of a setting include the table and the field name: `TCAdefaults.[table name].[field]` +This allows the `default` values of `TCA` fields available +for various TCA column types to be set or overridden, for instance for +:ref:`type=input `. -This key is also available on :ref:`User TSconfig level `, the order of default -values when creating new records in the backend is this: +Default values can be set at the type level: `TCAdefaults.[table name].[field].types.[type]` +or field level: `TCAdefaults.[table name].[field]` +This key is also available at the :ref:`User TSconfig level `. +The order of setting default values when creating new records in the backend is +this: + +#. Database field default value #. Value from `$GLOBALS['TCA']` -#. Value from :ref:`user TSconfig ` -#. Value from page TSconfig (these settings) +#. Field-level ref:`user TSconfig ` +#. Type-level ref:`user TSconfig ` +#. Field-level :typoscript:`TCAdefaults` configuration +#. Type-level :typoscript:`TCAdefaults` configuration #. Value from "defVals" GET variables #. Value from previous record based on :ref:`useColumnsForDefaultValues ` .. note:: - `TCAdefaults` is not applied to :ref:`FlexForm ` values. - These can only be addressed via :xml:`` elements within the + `TCAdefaults` are not applied to :ref:`FlexForm ` values. + These can only be set via :xml:`` elements within the FlexForm data structure. + .. _pageTsTcaDefaults-example: Example: Do not hide newly created pages by default @@ -37,3 +49,27 @@ Example: Do not hide newly created pages by default :caption: EXT:site_package/Configuration/page.tsconfig TCAdefaults.pages.hidden = 0 + +.. _pageTsTcaDefaults-example-type: + +Example: Set type specific default values +========================================= + +.. code-block:: typoscript + :caption: EXT:site_package/Configuration/page.tsconfig + + TCAdefaults.tt_content { + header_layout = 1 + header_layout.types { + textmedia = 3 + image = 2 + } + + frame_class = default + frame_class.types { + textmedia = ruler-before + image = none + } + + space_before_class = none + } diff --git a/Documentation/UserTsconfig/TcaDefaults.rst b/Documentation/UserTsconfig/TcaDefaults.rst index ba294c05..a5606c73 100644 --- a/Documentation/UserTsconfig/TcaDefaults.rst +++ b/Documentation/UserTsconfig/TcaDefaults.rst @@ -7,27 +7,39 @@ TCAdefaults =========== -This allows to set or override the `default` values of `TCA` fields that is available -for various TCA types, for instance for :ref:`type=input `. - -The full path of a setting include the table and the field name: `TCAdefaults.[table name].[field]` - -This key is also available on :ref:`Page TSconfig level `, the order of default -values when creating new records in the backend is this: - -#. Value from :php:`$GLOBALS['TCA']` -#. Value from User TSconfig (these settings) -#. Value from :ref:`Page TSconfig ` +.. versionadded:: 14.0 + The :typoscript:`TCAdefaults` configuration has been extended to support + type-specific syntax enabling different default values based on the record type. + +This allows `default` values of `TCA` fields that are available for various TCA +column types to be set or overridden, for instance for +:ref:`type=input `. + +Default values can be set at the type level: `TCAdefaults.[table name].[field].types.[type]` +or field level: `TCAdefaults.[table name].[field]` + +This key is also available at the :ref:`Page TSconfig level `. +The order that default values are set when creating new records in the backend +is this: + +#. Database field default value +#. Value from `$GLOBALS['TCA']` +#. Field-level ref:`user TSconfig ` +#. Type-level ref:`user TSconfig ` +#. Field-level :typoscript:`TCAdefaults` configuration +#. Type-level :typoscript:`TCAdefaults` configuration #. Value from "defVals" GET variables -#. Value from previous record based on 'useColumnsForDefaultValues' +#. Value from previous record based on + :ref:`useColumnsForDefaultValues ` -However the order for default values used by :php:`\TYPO3\CMS\Core\DataHandling\DataHandler` if a certain -field is not granted access to for user will be: +However, the order for default values used by the +:php:`\TYPO3\CMS\Core\DataHandling\DataHandler` if a particular field is inaccessible +to a user will be: #. Value from :php:`$GLOBALS['TCA']` #. Value from User TSconfig (these settings) -So these values will be authoritative if the user has no access to the field anyway. +So these will be the values that are set if the user has no access to the field anyway. Example: @@ -62,3 +74,25 @@ of an extension: :caption: EXT:site_package/Configuration/TCA/Overrides/pages.php $GLOBALS['TCA']['pages']['ctrl']['useColumnsForDefaultValues'] = 'doktype,fe_group'; + +.. _userTsTcaDefaults-example-types: + +Example: Set type specific default values in user TSconfig +========================================================== + +.. code-block:: typoscript + :caption: EXT:site_package/Configuration/user.tsconfig + + TCAdefaults.tt_content { + header_layout = 1 + # Use specific default values for certain types + header_layout.types { + textmedia = 3 + image = 2 + } + } + +In this example: if a user with no write access to the field `tt_content.header_layout` +creates a new content element of type `textmedia` the header layout will be set +to 3. If the user does have write access to the field, 3 will be used by default +and they may change it.