From 3bdeeea2bc580f4e96a6859bab8441c136c4c082 Mon Sep 17 00:00:00 2001 From: Christian Rath-Ulrich Date: Fri, 9 Jan 2026 11:43:38 +0100 Subject: [PATCH] [FEATURE] Add FlexForm configuration for glossary plugin and enhance TermController with starting point handling #243 --- Classes/Controller/TermController.php | 21 ++++++++++ Configuration/FlexForms/List.xml | 48 ++++++++++++++++++++++ Configuration/TCA/Overrides/tt_content.php | 41 ++++++++++++++---- Resources/Private/Language/locallang.xlf | 9 ++++ 4 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 Configuration/FlexForms/List.xml diff --git a/Classes/Controller/TermController.php b/Classes/Controller/TermController.php index 4b301e6..5eabace 100755 --- a/Classes/Controller/TermController.php +++ b/Classes/Controller/TermController.php @@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Frontend\Controller\ErrorController; @@ -66,6 +67,26 @@ public function initializeAction(): void $frameworkConfiguration['persistence']['storagePid'] ?? '', true ); + + // Override storagePids with startingpoint from FlexForm if set + if ( + isset($this->settings['startingpoint']) && + (string)$this->settings['startingpoint'] !== '' + ) { + $startingPointPids = GeneralUtility::intExplode( + ',', + $this->settings['startingpoint'], + true + ); + if (count($startingPointPids)) { + $this->storagePids = $startingPointPids; + } + } + + // Set query settings with storagePids + $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); + $querySettings->setStoragePageIds($this->storagePids); + $this->termRepository->setDefaultQuerySettings($querySettings); } /** diff --git a/Configuration/FlexForms/List.xml b/Configuration/FlexForms/List.xml new file mode 100644 index 0000000..f578683 --- /dev/null +++ b/Configuration/FlexForms/List.xml @@ -0,0 +1,48 @@ + + + + + + LLL:EXT:dpn_glossary/Resources/Private/Language/locallang.xlf:tx_dpnglossary.flexforms.preview + array + + + + +
1
+ select + selectSingle + + + LLL:EXT:dpn_glossary/Resources/Private/Language/locallang.xlf:plugin.list_mode.normal + normal + + + LLL:EXT:dpn_glossary/Resources/Private/Language/locallang.xlf:plugin.list_mode.character + character + + + LLL:EXT:dpn_glossary/Resources/Private/Language/locallang.xlf:plugin.list_mode.pagination + pagination + + + pagination +
+
+ + + + group + db + pages + 3 + 50 + 0 + + +
+
+
+
+
+ diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 5154815..273e65a 100755 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -40,23 +40,46 @@ function () { 'special' ); + // Add FlexForm for main glossary plugin + ExtensionManagementUtility::addPiFlexFormValue( + '*', + 'FILE:EXT:dpn_glossary/Configuration/FlexForms/List.xml', + 'dpnglossary_glossary' + ); + ExtensionManagementUtility::addToAllTCAtypes( + 'tt_content', + '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,pi_flexform', + 'dpnglossary_glossary', + 'after:header' + ); + $flexforms = [ - 'dpnglossary_glossary' => null, 'dpnglossary_glossarypreviewnewest' => '/Configuration/FlexForms/PreviewNewest.xml', 'dpnglossary_glossarypreviewrandom' => '/Configuration/FlexForms/PreviewRandom.xml', 'dpnglossary_glossarypreviewselected' => '/Configuration/FlexForms/PreviewSelected.xml', ]; foreach ($flexforms as $cType => $flexform) { - if ($flexform !== null) { - ExtensionManagementUtility::addPiFlexFormValue('*', 'FILE:EXT:dpn_glossary' . $flexform, $cType); + ExtensionManagementUtility::addPiFlexFormValue('*', 'FILE:EXT:dpn_glossary' . $flexform, $cType); + + ExtensionManagementUtility::addToAllTCAtypes( + 'tt_content', + '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,pi_flexform', + $cType, + 'after:header' + ); + } + + // Hide preview plugins from CType selector + $pluginsToHide = [ + 'dpnglossary_glossarypreviewnewest', + 'dpnglossary_glossarypreviewrandom', + 'dpnglossary_glossarypreviewselected', + ]; - ExtensionManagementUtility::addToAllTCAtypes( - 'tt_content', - '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,pi_flexform', - $cType, - 'after:header' - ); + foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $key => $item) { + if (isset($item['value']) && in_array($item['value'], $pluginsToHide, true)) { + unset($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][$key]); } } diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 22dfc36..feb27ed 100755 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -157,6 +157,15 @@ Limit + + Normal + + + Character + + + Pagination +