Attention
TYPO3 v12 has reached end-of-life as of April 30th 2026 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v12 here: TYPO3 ELTS.
IsContentUsedOnPageLayoutEvent
New in version 12.0
This event
\TYPO3\
serves as a drop-in replacement for the removed
$GLOBALS
hook.
Use the PSR-14 event
\TYPO3\
to identify if content has been used in a column that is not in a backend layout.
Setting
$event->set prevent the following message for the affected content element,
setting it to false displays it:
Warning
Unused elements detected on this page These elements don't belong to any of the available columns of this page. You should either delete them or move them to existing columns. We highlighted the problematic records for you.
Example: Display "Unused elements detected on this page" for elements with missing parent
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Listener;
use TYPO3\CMS\Backend\View\Event\IsContentUsedOnPageLayoutEvent;
final class ContentUsedOnPage
{
public function __invoke(IsContentUsedOnPageLayoutEvent $event): void
{
// Get the current record from the event.
$record = $event->getRecord();
// This code will be your domain logic to indicate if content
// should be hidden in the page module.
if ((int)($record['colPos'] ?? 0) === 999
&& !empty($record['tx_myext_content_parent'])
) {
// Flag the current element as not used. Set it to true, if you
// want to flag it as used and hide it from the page module.
$event->setUsed(false);
}
}
}
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Listener;
use TYPO3\CMS\Backend\View\Event\IsContentUsedOnPageLayoutEvent;
final class ContentUsedOnPage
{
public function __invoke(IsContentUsedOnPageLayoutEvent $event): void
{
// Get the current record from the event.
$record = $event->getRecord();
// This code will be your domain logic to indicate if content
// should be hidden in the page module.
if ((int)($record['colPos'] ?? 0) === 999
&& !empty($record['tx_myext_content_parent'])
) {
// Flag the current element as not used. Set it to true, if you
// want to flag it as used and hide it from the page module.
$event->setUsed(false);
}
}
}