diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index 271269e81baa25b24a12199e9042c4eba582cb62..056c03e8a223efc1cda9d8ae025bbdcd0b9a1616 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -1615,8 +1615,14 @@ class PageLayoutView implements LoggerAwareInterface // Traverse any selected elements and render their display code: $results = $this->getResult($queryBuilder->execute()); $unused = []; + $hookArray = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['record_is_used'] ?? []; foreach ($results as $record) { - if (isset($columns[$record['colPos']])) { + $used = isset($columns[$record['colPos']]); + foreach ($hookArray as $_funcRef) { + $_params = ['columns' => $columns, 'record' => $record, 'used' => $used]; + $used = GeneralUtility::callUserFunction($_funcRef, $_params, $this); + } + if ($used) { $columnValue = (string)$record['colPos']; $contentRecordsPerColumn[$columnValue][] = $record; } else { diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-82213-NewHookToDetermineIfContentRecordIsUsedUnused.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-82213-NewHookToDetermineIfContentRecordIsUsedUnused.rst new file mode 100644 index 0000000000000000000000000000000000000000..e95ac27b9bcf0b0d19990653c76b6bf0a9f69115 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-82213-NewHookToDetermineIfContentRecordIsUsedUnused.rst @@ -0,0 +1,48 @@ +.. include:: ../../Includes.txt + +======================================================================== +Feature: #82213 - New hook to determine if content record is used/unused +======================================================================== + +See :issue:`82213` + +Description +=========== + +A new hook has been added to the `PageLayoutView` class, determining whether a +content record is used or not. The hook allows third party code to change the +`$used` parameter by returning a boolean, thus changing which content records +are shown in the "unused content elements" section of the backend page module. + + +Impact +====== + +Without providing an own hook, content elements with an colPos not defined within +the current backend layout are marked as unused. You have to register and provide +an own PHP class checking if an content record is used within your configuration. + +.. code-block:: php + + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['record_is_used']['myExt'] = + MyExt\MyExt\Hooks\PageLayoutViewHook::class . '->contentIsUsed'; + +.. code-block:: php + + namespace MyExt\MyExt\Hooks; + + use TYPO3\CMS\Backend\View\PageLayoutView; + + class PageLayoutViewHook + { + public function contentIsUsed(array $params, PageLayoutView $parentObject): bool + { + if ($params['used']) { + return true; + } + $record = $params['record']; + return $record['colPos'] === 999 && !empty($record['tx_myext_content_parent']); + } + } + +.. index:: Backend