Project

General

Profile

Actions

Bug #105605

closed

addToAllTCAtypes() while restricting to custom DokType

Added by Lukas Wittmann 6 days ago. Updated 3 days ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2024-11-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hello TYPO3 Team,
I build a new dokType in my ext_tables.php. I registered it in my TCA/Overrides/pages.php and wanted to add a new palette to my general tab like shown in the following code example:
ext_tables.php:

// Define a new doktype
$customPageDoktype = 198;
// Add page type to system
$dokTypeRegistry = GeneralUtility::makeInstance(PageDoktypeRegistry::class);
$dokTypeRegistry->add(
    $customPageDoktype,
    [
        'allowedTables' => '*',
    ],
);

Configuration/TCA/Overrides/pages.php:

    // Add the new doktype to the page type selector
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
        'pages',
        'doktype',
        [
            'label' => 'label',
            'value' => '198',
            'group' => 'Journal',
        ],
        '198',
        'after'
    );

    $tempColumns = [
        'testField' => [
            'label' => 'journal',
            'config' => [
                'type' => 'input',
            ]
        ]
    ];

    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
        'pages',
        $tempColumns
    );

    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
        'pages',
        'testPalette',
        'testField'
    );
    // did not work
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
        'pages',
        '--palette--;' . $label . ';testPalette',
        '198',
        'before:title'
    );

Problem:
The addToAllTCAtypes() function didn't work out as expected and did not add it in my BE.
If I removed the 198 dokType it worked for all dokType.

Solution:
After adding the following line infront of the addToAllTCAtypes() call it fixed my problem:
Configuration/TCA/Overrides/pages.php:

$GLOBALS['TCA']['pages']['types']['198'] = $GLOBALS['TCA']['pages']['types']['1'];

Actions #1

Updated by Lukas Wittmann 6 days ago

  • Description updated (diff)
Actions #2

Updated by Lukas Wittmann 6 days ago

  • Description updated (diff)
Actions #3

Updated by Nikita Hovratov 3 days ago

Looks like the documentation went missing since v12. In v11, it's still documented to copy the default showitems from standard page: https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/PageTypes/CreateNewPageType.html

Actions #4

Updated by Nikita Hovratov 3 days ago

  • Status changed from New to Closed

Created an issue in the documentation repo: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/issues/5050

As this is not a Core bug, but missing documentation I'll close this issue.

Actions

Also available in: Atom PDF