简体   繁体   中英

backend layout and drag&drop for custom content elements holding tt_content children | TYPO3 11

I've created a custom content element Box on TYPO3 11 core which has a field of type inline for further children elements of tt_content. The frontend works just fine so far, but the backend view gives me headache.

Creating the children elements on the parent Box , they're assigned colPos 0 and appear in that column of my backend layout.

盒子

后端视图

What I'd like to achieve is having a backend layout inside my Box and being able to drag & drop tt_content elements in and out freely, looking like this:看起来像这样

The docs I followed appeared to not fit my desire and I want to solve this without any extensions.

Here's my TCA and SQL so far

$col = [
    'content_relation' => [
        'exclude' => true,
        'label' => 'content',
        'config' => [
            'type' => 'inline',
            'allowed' => 'tt_content',
            'foreign_table' => 'tt_content',
            'foreign_field' => 'content_relation',
            'foreign_sortby' => 'sorting',
            'minitems' => 0,
            'maxitems' => 99,
            'appearance' => [
                'collapseAll' => true,
                'expandSingle' => true,
                'levelLinksPosition' => 'bottom',
                'useSortable' => true,
                'showPossibleLocalizationRecords' => true,
                'showRemovedLocalizationRecords' => true,
                'showAllLocalizationLink' => true,
                'showSynchronizationLink' => true,
                'enabledControls' => [
                    'info' => TRUE,
                    'new' => TRUE,
                    'dragdrop' => TRUE,
                    'sort' => TRUE,
                    'hide' => TRUE,
                    'delete' => TRUE,
                    'localize' => TRUE,
                ],
            ],
        ],
    ],
];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tt_content', 'content_relation');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $col);

$GLOBALS['TCA']['tt_content']['types']['dg_template_box'] = [
    'showitem' => '
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
            --palette--;;general,
                header;Internal title (not displayed),
                content_relation;Elemente,
        ',
];

CREATE TABLE tt_content (
    content_relation int(11) unsigned DEFAULT '0',
);

I assume you would need to change the colPos of your content_relation field. Assuming that Inhalt displays content elements from the tt_content table of the colPos 0. When creating a new content_relation record it'll (logically) display inside your normal ( Inhalt ) backend-layout since it represents records with a colPos which equals 0.

The easiest way is that you should make use of the b13/container package/extension. You can simply create a new custom "box"-container with all your custom TCA configuration - and the best part is that the extension will take care of the children tt_content records itself. :)

For examples on how-to-use the b13/container extension take a look here b13/container-example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM