diff --git a/Classes/Listener/BeforeContainerConfigurationIsApplied.php b/Classes/Listener/BeforeContainerConfigurationIsApplied.php index 52dea1d..584a748 100644 --- a/Classes/Listener/BeforeContainerConfigurationIsApplied.php +++ b/Classes/Listener/BeforeContainerConfigurationIsApplied.php @@ -21,7 +21,7 @@ public function __invoke(BeforeContainerConfigurationIsAppliedEvent $e) $configuration = $e->getContainerConfiguration(); if ($configuration->getCType() === 'b13-2cols') { $configuration->setDescription('mod -- ' . $configuration->getDescription()); - $configuration->changeGridColumnConfiguration(201, ['disallowed' => ['CType' => 'uploads, image']]); + $configuration->changeGridColumnConfiguration(201, ['disallowedContentTypes' => 'uploads, image']); } } } diff --git a/Configuration/Sets/ContainerExampleContentArea/config.yaml b/Configuration/Sets/ContainerExampleContentArea/config.yaml new file mode 100644 index 0000000..04aa21c --- /dev/null +++ b/Configuration/Sets/ContainerExampleContentArea/config.yaml @@ -0,0 +1,4 @@ +name: b13/container-example/content-area +label: Container Example with Content Area Renderer +dependencies: + - typo3/fluid-styled-content \ No newline at end of file diff --git a/Configuration/Sets/ContainerExampleContentArea/setup.typoscript b/Configuration/Sets/ContainerExampleContentArea/setup.typoscript new file mode 100644 index 0000000..ed4dd7f --- /dev/null +++ b/Configuration/Sets/ContainerExampleContentArea/setup.typoscript @@ -0,0 +1,12 @@ +tt_content.b13-2cols < lib.contentElement +tt_content.b13-2cols { + templateName = 2Cols + templateRootPaths.10 = EXT:container_example/Resources/Private/ContentAreaTemplates + dataProcessing.10 = B13\Container\DataProcessing\ContentAreaProcessor +} +tt_content.b13-2cols-with-header-container < lib.contentElement +tt_content.b13-2cols-with-header-container { + templateName = 2ColsWithHeader + templateRootPaths.10 = EXT:container_example/Resources/Private/ContentAreaTemplates + dataProcessing.10 = B13\Container\DataProcessing\ContentAreaProcessor +} diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 28e61f6..9f85569 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -1,14 +1,24 @@ configureContainer( - ( +call_user_func(static function () { + + $typo3 = (new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion(); + $restrictionKey = 'allowedContentTypes'; + $restrictions = 'header, textmedia, b13-2cols'; + if ($typo3 < 14) { + $restrictionKey = 'allowed'; + $restrictions = ['CType' => 'header, textmedia, b13-2cols']; + } + + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer( + ( new \B13\Container\Tca\ContainerConfiguration( 'b13-2cols-with-header-container', // CType '2 Column Container With Header', // label 'Some Description of the Container', // description [ [ - ['name' => 'header', 'colPos' => 200, 'colspan' => 2, 'allowed' => ['CType' => 'header, textmedia, b13-2cols']] + ['name' => 'header', 'colPos' => 200, 'colspan' => 2, $restrictionKey => $restrictions] ], [ ['name' => 'left side', 'colPos' => 201], @@ -16,19 +26,25 @@ ] ] // grid configuration ) - ) - // override default configurations - ->setIcon('EXT:container_example/Resources/Public/Icons/b13-2cols-with-header-container.svg') - ->setSaveAndCloseInNewContentElementWizard(false) - ->setDefaultValues(['header' => 'my-default-value-header']) -); + ) + // override default configurations + ->setIcon('EXT:container_example/Resources/Public/Icons/b13-2cols-with-header-container.svg') + ->setSaveAndCloseInNewContentElementWizard(false) + ->setDefaultValues(['header' => 'my-default-value-header']) + ); // override default settings -$GLOBALS['TCA']['tt_content']['types']['b13-2cols-with-header-container']['showitem'] = 'sys_language_uid,CType,header,tx_container_parent,colPos'; + $GLOBALS['TCA']['tt_content']['types']['b13-2cols-with-header-container']['showitem'] = 'sys_language_uid,CType,header,tx_container_parent,colPos'; + $restrictionKey = 'allowedContentTypes'; + $restrictions = 'header'; + if ($typo3 < 14) { + $restrictionKey = 'allowed'; + $restrictions = ['CType' => 'header']; + } // second container -\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer( - ( + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer( + ( new \B13\Container\Tca\ContainerConfiguration( 'b13-2cols', // CType '2 Column', // label @@ -36,14 +52,14 @@ [ [ ['name' => '2-cols-left', 'colPos' => 200, 'maxitems' => 1], - ['name' => '2-cols-right', 'colPos' => 201, 'allowed' => ['CType' => 'header']] + ['name' => '2-cols-right', 'colPos' => 201, $restrictionKey => $restrictions] ] ] // grid configuration ) - )->setBackendTemplate('EXT:container_example/Resources/Private/Templates/BackendTemplate.html') -); -\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer( - ( + )->setBackendTemplate('EXT:container_example/Resources/Private/Templates/BackendTemplate.html') + ); + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer( + ( new \B13\Container\Tca\ContainerConfiguration( 'b13-1col', // CType '1 Column', // label @@ -54,5 +70,7 @@ ] ] // grid configuration ) - )->setRegisterInNewContentElementWizard(false) -); + )->setRegisterInNewContentElementWizard(false) + ); +}); + diff --git a/Configuration/TypoScript/2cols.typoscript b/Configuration/TypoScript/2cols.typoscript deleted file mode 100644 index 03a10f7..0000000 --- a/Configuration/TypoScript/2cols.typoscript +++ /dev/null @@ -1 +0,0 @@ -@import 'EXT:container_example/Configuration/Sets/ContainerExample/TypoScript/2Cols/setup.typoscript' \ No newline at end of file diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript deleted file mode 100644 index 393759f..0000000 --- a/Configuration/TypoScript/setup.typoscript +++ /dev/null @@ -1 +0,0 @@ -@import 'EXT:container_example/Configuration/Sets/ContainerExample/TypoScript/2ColsWithHeader/setup.typoscript' \ No newline at end of file diff --git a/Resources/Private/ContentAreaTemplates/2Cols.html b/Resources/Private/ContentAreaTemplates/2Cols.html new file mode 100644 index 0000000..b663fc4 --- /dev/null +++ b/Resources/Private/ContentAreaTemplates/2Cols.html @@ -0,0 +1,9 @@ + + + + {record.header} + + {record.media.identifier} + + + \ No newline at end of file diff --git a/Resources/Private/ContentAreaTemplates/2ColsWithHeader.html b/Resources/Private/ContentAreaTemplates/2ColsWithHeader.html new file mode 100644 index 0000000..8eb7322 --- /dev/null +++ b/Resources/Private/ContentAreaTemplates/2ColsWithHeader.html @@ -0,0 +1,14 @@ + +

{data.header}

+ + +
{content.200 -> f:render.contentArea()}
+
+ + + {record -> f:render.record()} + + + +
{content.202 -> f:render.contentArea()}
+
\ No newline at end of file diff --git a/Resources/Private/Templates/BackendTemplate.html b/Resources/Private/Templates/BackendTemplate.html index fe10b44..ffcaf38 100644 --- a/Resources/Private/Templates/BackendTemplate.html +++ b/Resources/Private/Templates/BackendTemplate.html @@ -2,6 +2,8 @@ xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true" > +

custom backend template

+ {record.tx_container_grid} {tx_container_grid} diff --git a/composer.json b/composer.json index 4a7466c..297e650 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "b13/container-example", - "description": "Example for EXT:container", + "description": "Container Example - Example for EXT:container", "type": "typo3-cms-extension", "homepage": "https://b13.com", "license": ["GPL-2.0-or-later"], @@ -14,7 +14,11 @@ }, "extra": { "typo3/cms": { - "extension-key": "container_example" + "extension-key": "container_example", + "version": "1.0.0", + "Package": { + "providesPackages": {} + } } } }