ModifyRenderedContentAreaEvent 

The ModifyRenderedContentAreaEvent is fired after the f:render.contentArea ViewHelper rendered a content area, which is the HTML of every record in one column of the backend layout. A listener reads the HTML with getRenderedContentArea() and replaces it with setRenderedContentArea() .

getContentArea() returns the ContentArea , which answers the name and the identifier of the area, its colPos, its slide mode, and the records it collected. Whatever a listener writes goes into the page as it is, so escape the parts that come from a record.

To change a single record instead of a whole area, use ModifyRenderedRecordEvent.

Example 

The following listener marks an area that rendered no record, which makes a gap in a layout visible during development:

EXT:my_extension/Classes/EventListener/WrapRenderedContentAreaListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Fluid\Event\ModifyRenderedContentAreaEvent;

final readonly class WrapRenderedContentAreaListener
{
  #[AsEventListener('my_extension/wrap-rendered-content-area')]
  public function __invoke(ModifyRenderedContentAreaEvent $event): void
  {
    $contentArea = $event->getContentArea();
    if ($contentArea->getRecords() !== []) {
      return;
    }
    // Mark an area that rendered nothing, to find gaps in a layout
    $event->setRenderedContentArea(sprintf(
      '<div class="my-empty-area">%s is empty</div>',
      htmlspecialchars($contentArea->getName()),
    ));
  }
}
Copied!

API 

final class ModifyRenderedContentAreaEvent
Fully qualified name
\TYPO3\CMS\Fluid\Event\ModifyRenderedContentAreaEvent

Event to modify the rendered content area output.

This can be used to alter the final HTML of a content area, for example to render a debug wrapper around it.

getRenderedContentArea()
Returns
string
setRenderedContentArea(string $renderedContentArea)

Set the rendered content area's HTML.

Make sure to return escaped content if necessary.

param $renderedContentArea

the renderedContentArea

getContentArea()
Returns
\TYPO3\CMS\Core\Page\ContentArea
getRequest()
Returns
\Psr\Http\Message\ServerRequestInterface