diff --git a/Classes/Backend/Hook/DataHandlerSlugUpdateHook.php b/Classes/Backend/Hook/DataHandlerSlugUpdateHook.php index 4cff6d0..db4387d 100644 --- a/Classes/Backend/Hook/DataHandlerSlugUpdateHook.php +++ b/Classes/Backend/Hook/DataHandlerSlugUpdateHook.php @@ -53,6 +53,15 @@ public function processDatamap_preProcessFieldArray( $id, DataHandler $dataHandler ): void { + if ( + 'pages' === $table && !MathUtility::canBeInterpretedAsInteger($id)){ + //new page was created + $synchronizeOn = (bool) Configuration::get('synchronize_on'); + if ($synchronizeOn){ + $incomingFieldArray['tx_sluggi_sync'] = 1; + } + return; + } if ( 'pages' !== $table // This is set in \TYPO3\CMS\Backend\History\RecordHistoryRollback::performRollback, @@ -185,4 +194,4 @@ protected function isNestedHookInvocation(DataHandler $dataHandler): bool return in_array(\TYPO3\CMS\Redirects\Service\SlugService::CORRELATION_ID_IDENTIFIER, $correlationIdAspects, true); } -} \ No newline at end of file +} diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index 531dc5c..d6f040d 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -83,7 +83,7 @@ function array_flatten($array): array { 'labelUnchecked' => 'LLL:EXT:sluggi/Resources/Private/Language/locallang.xlf:pages.tx_sluggi_sync.disabled' ] ], - 'default' => 1 + 'default' => 0 ] ] ]; diff --git a/ext_conf_template.txt b/ext_conf_template.txt index b592db9..f69e3fd 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -6,5 +6,7 @@ slash_replacement = 1 pages_fields = [["nav_title","title"]] # cat=basic; type=boolean; label=Enable synchronization of slug segment with configured page fields synchronize = 1 +# cat=basic; type=boolean; label=Turn on synchronization of slug segment with configured page fields +synchronize_on = 0 # cat=basic; type=boolean; label=Allow standard editors only editing of the last segment of the URL (single page) last_segment_only = 0 diff --git a/ext_tables.sql b/ext_tables.sql index f2451d0..498195e 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -3,5 +3,5 @@ # CREATE TABLE pages ( tx_sluggi_lock SMALLINT(5) UNSIGNED DEFAULT '0' NOT NULL, - tx_sluggi_sync SMALLINT(5) UNSIGNED DEFAULT '1' NOT NULL + tx_sluggi_sync SMALLINT(5) UNSIGNED DEFAULT '0' NOT NULL );