From 57552216af61c2103af8cc1787745779a7e2bd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20M=C3=BCller?= <typo3@brotkrueml.dev> Date: Tue, 3 Sep 2024 19:30:00 +0200 Subject: [PATCH] [DOCS] Improve changelog for auto-registration of new ce wizard via TCA The given migration examples were not really practical, as an integrator does not return an array, but use either the API for adding a new content element/plugin, or manipulate the TCA array directly via `Configuration/TCA/Overrides/tt_content.php` for adding `saveAndClose` or `defaultValues`. To ease the work for integrators when migrating to the new options, the examples have been improved. Additionally, captions for the files have been added to ease grasping the context of the examples. Resolves: #104806 Related: #102834 Releases: main Change-Id: Idc840c611751be79dec475d372c9a2f29d23f32f Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85860 Tested-by: Garvin Hicking <gh@faktor-e.de> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Garvin Hicking <gh@faktor-e.de> --- ...trationOfNewContentElementWizardViaTCA.rst | 163 +++++++++++------- 1 file changed, 100 insertions(+), 63 deletions(-) diff --git a/typo3/sysext/core/Documentation/Changelog/13.0/Feature-102834-Auto-registrationOfNewContentElementWizardViaTCA.rst b/typo3/sysext/core/Documentation/Changelog/13.0/Feature-102834-Auto-registrationOfNewContentElementWizardViaTCA.rst index 3f925cd2b999..d34147362739 100644 --- a/typo3/sysext/core/Documentation/Changelog/13.0/Feature-102834-Auto-registrationOfNewContentElementWizardViaTCA.rst +++ b/typo3/sysext/core/Documentation/Changelog/13.0/Feature-102834-Auto-registrationOfNewContentElementWizardViaTCA.rst @@ -20,45 +20,61 @@ and :php:`icon` are used to define the wizard entry. The migration looks as follows: -.. code-block:: typoscript +Before: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/page.tsconfig # Add a new element (header) to the "common" group mod.wizards.newContentElement.wizardItems.common.elements.header { - iconIdentifier = content-header - title = LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:common_headerOnly_title - description = LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:common_headerOnly_description - tt_content_defValues { - CType = header - } + iconIdentifier = content-header + title = LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:common_headerOnly_title + description = LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:common_headerOnly_description + tt_content_defValues { + CType = header + } } mod.wizards.newContentElement.wizardItems.common.show := addToList(header) -.. code-block:: php +After: - <?php +.. code-block:: php + :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php + :emphasize-lines: 7-9 - return [ - 'columns' => [ - 'CType' => [ - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.type', - 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'items' => [ - [ - 'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header', - 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header.description', - 'value' => 'header', - 'icon' => 'content-header', - 'group' => 'default', - ], - ], - ], - ], + // use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; + + ExtensionManagementUtility::addPlugin( + [ + 'label' => 'LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:common_headerOnly_title' + 'description' => 'LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:common_headerOnly_description', + 'group' => 'default', + 'value' => 'header', + 'icon' => 'content-header', ], - ]; + 'CType', + 'my_extension', + ); + +And for an Extbase plugin: + +.. code-block:: php + :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php + :emphasize-lines: 7-9 + + // use TYPO3\CMS\Extbase\Utility\ExtensionUtility; -.. note:: + ExtensionUtility::registerPlugin( + 'my_extension', // extension name + 'my_plugin', // plugin name + 'My plugin title', // plugin title + 'my-icon', // icon identifier + 'default', // group + 'My plugin description' // plugin description + ); + + +.. note:: Probably it will only be necessary to migrate the :typoscript:`description`, as the other values are already set most of the time. This can be done @@ -70,75 +86,95 @@ The migration looks as follows: The :typoscript:`saveAndClose` option is now defined through TCA as well: -.. code-block:: typoscript +Before: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/page.tsconfig mod.wizards.newContentElement.wizardItems { - special.elements { - div { - saveAndClose = 1 - } + special.elements { + div { + saveAndClose = 1 } + } } -.. code-block:: php +After: + +.. code-block:: php + :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php <?php - return [ - 'types' => [ - 'div' => [ - 'creationOptions' => [ - 'saveAndClose' => true, + $GLOBALS['TCA']['tt_content'] = array_merge_recursive( + $GLOBALS['TCA']['tt_content'], + [ + 'types' => [ + 'div' => [ + 'creationOptions' => [ + 'saveAndClose' => true, + ], ], ], - ], - ]; + ] + ); -The same goes for the default values. The option has been renamed from +The same applies to the default values. The option has been renamed from `tt_content_defValues` to `defaultValues`: -.. code-block:: typoscript +Before: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/page.tsconfig mod.wizards.newContentElement.wizardItems { - special.elements { - html { - tt_content_defValues { - bodytext = some text - } - } + special.elements { + html { + tt_content_defValues { + bodytext = some text + } } + } } -.. code-block:: php +After: + +.. code-block:: php + :caption: EXT:my_extension/Configuration/TCA/Overrides/tt_content.php <?php - return [ - 'types' => [ - 'html' => [ - 'creationOptions' => [ - 'defaultValues' => [ - 'bodytext' => 'some text' + $GLOBALS['TCA']['tt_content'] = array_merge_recursive( + $GLOBALS['TCA']['tt_content'], + [ + 'types' => [ + 'html' => [ + 'creationOptions' => [ + 'defaultValues' => [ + 'bodytext' => 'some text' + ], ], ], ], - ], - ]; + ] + ); Removing items from the select box still works as before through page TSconfig :typoscript:`TCEFORM`. This will remove both the TCA items entry and the wizard entry. -.. code-block:: typoscript +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/page.tsconfig TCEFORM.tt_content.CType { - removeItems := addToList(header) + removeItems := addToList(header) } To hide groups or elements in the wizard a new option :typoscript:`removeItems` is available. -.. code-block:: typoscript +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/page.tsconfig # Before mod.wizards.newContentElement.wizardItems.special.show := removeFromList(html) @@ -148,7 +184,8 @@ is available. As mentioned, it's also possible to remove a whole group: -.. code-block:: typoscript +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/page.tsconfig # This will remove the "menu" group mod.wizards.newContentElement.wizardItems.removeItems := addToList(menu) -- GitLab