diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php index b2647da33c704d35748387536f68a89f21548a66..c778e83f61123545d0e22fdd8195f45f6554ecd3 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php @@ -101,6 +101,11 @@ class NewContentElementController */ protected $moduleTemplate; + /** + * @var UriBuilder + */ + protected $uriBuilder; + /** * Constructor */ @@ -110,6 +115,7 @@ class NewContentElementController $GLOBALS['SOBE'] = $this; $this->view = $this->getFluidTemplateObject(); $this->menuItemView = $this->getFluidTemplateObject('MenuItem.html'); + $this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); } /** @@ -178,8 +184,7 @@ class NewContentElementController protected function onClickInsertRecord(string $clientContext): string { // $this->uid_pid can be negative (= pointing to tt_content record) or positive (= "page ID") - $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); - $location = (string)$uriBuilder->buildUriFromRoute('record_edit', [ + $location = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [ 'edit[tt_content][' . $this->uid_pid . ']' => 'new', 'defVals[tt_content][colPos]' => $this->colPos, 'defVals[tt_content][sys_language_uid]' => $this->sys_language, @@ -254,6 +259,20 @@ class NewContentElementController $aOnClick = "document.editForm.defValues.value=unescape('" . rawurlencode($wInfo['params']) . "');goToalt_doc();"; } + // Go to DataHandler directly instead of FormEngine + if ($wInfo['saveAndClose'] ?? false) { + $urlParams = []; + $id = uniqid('NEW'); + parse_str($wInfo['params'], $urlParams); + $urlParams['data']['tt_content'][$id] = $urlParams['defVals']['tt_content'] ?? []; + $urlParams['data']['tt_content'][$id]['colPos'] = $this->colPos; + $urlParams['data']['tt_content'][$id]['pid'] = $this->uid_pid; + $urlParams['data']['tt_content'][$id]['sys_language_uid'] = $this->sys_language; + $urlParams['redirect'] = GeneralUtility::_GP('returnUrl'); + unset($urlParams['defVals']); + $url = $this->uriBuilder->buildUriFromRoute('tce_db', $urlParams); + $aOnClick = 'list_frame.location.href=' . GeneralUtility::quoteJSvalue((string)$url) . '; return false'; + } $icon = $this->moduleTemplate->getIconFactory()->getIcon($wInfo['iconIdentifier'])->render(); $this->menuItemView->assignMultiple([ @@ -410,6 +429,7 @@ class NewContentElementController { $itemConf['title'] = $this->getLanguageService()->sL($itemConf['title']); $itemConf['description'] = $this->getLanguageService()->sL($itemConf['description']); + $itemConf['saveAndClose'] = (bool)$itemConf['saveAndClose']; $itemConf['tt_content_defValues'] = $itemConf['tt_content_defValues.']; unset($itemConf['tt_content_defValues.']); return $itemConf; diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-90461-QuickCreateContentElementsViaNewContentElementWizard.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-90461-QuickCreateContentElementsViaNewContentElementWizard.rst new file mode 100644 index 0000000000000000000000000000000000000000..9e268e564fed087aa7b29499f5129f8a88678c35 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-90461-QuickCreateContentElementsViaNewContentElementWizard.rst @@ -0,0 +1,45 @@ +.. include:: ../../Includes.txt + +=========================================================================== +Feature: #90461 - Quick-Create Content Elements via NewContentElementWizard +=========================================================================== + +See :issue:`90461` + +Description +=========== + +The new Content Element wizard within the Page Module now contains +an option called "saveAndClose" which directs a user back to the +Page Module directly instead of showing the FormEngine. + +This is especially useful for custom content elements or container +content types where pre-defined values can be put in place directly, +saving editors one click on content creation. + +The functionality is disabled by default, but explicitly enabled for the Content Type "divider". + + +Impact +====== + +This definition can be put into PageTSconfig (e.g. EXT:my_extension/Configuration/Page/main.tsconfig) with the new flag "saveAndClose" enabled. + +.. code-block:: typoscript + + mod.wizards.newContentElement.wizardItems { + common.elements { + my_element { + iconIdentifier = content-my-icon + title = LLL:EXT:my_extension/Resources/Private/Language/ContentTypes.xlf:my_element_title + description = LLL:EXT:my_extension/Resources/Private/Language/ContentTypes.xlf:my_element_description + tt_content_defValues { + CType = my_element + header = Hello my friend + } + saveAndClose = true + } + } + } + +.. index:: Backend, TSConfig, ext:backend \ No newline at end of file diff --git a/typo3/sysext/frontend/Configuration/TSconfig/Page/Mod/Wizards/NewContentElement.tsconfig b/typo3/sysext/frontend/Configuration/TSconfig/Page/Mod/Wizards/NewContentElement.tsconfig index 7a03f6912b08247b9dc800418c2b8b5c06e8c328..cbb66d638c5afea2e53ead2578e0806fdd41e3c6 100644 --- a/typo3/sysext/frontend/Configuration/TSconfig/Page/Mod/Wizards/NewContentElement.tsconfig +++ b/typo3/sysext/frontend/Configuration/TSconfig/Page/Mod/Wizards/NewContentElement.tsconfig @@ -192,6 +192,7 @@ mod.wizards.newContentElement.wizardItems { tt_content_defValues { CType = div } + saveAndClose = true } shortcut { iconIdentifier = content-special-shortcut