ModifyRenderedRecordEvent 

The ModifyRenderedRecordEvent is fired after the f:render.record ViewHelper rendered one record, and before the result reaches the template. A listener reads the HTML with getRenderedRecord() and replaces it with setRenderedRecord() , for example to wrap a content element in markup of its own.

Without the argument recordAs, the f:render.contentArea ViewHelper renders each record of the area with f:render.record, so the event is fired for these records as well. With recordAs, the event is only fired if the content of the tag renders the record with f:render.record.

The event also carries the record and the request. Whatever a listener writes goes into the page as it is, so escape the parts that come from the record.

To change a whole column of the backend layout instead of a single record, use ModifyRenderedContentAreaEvent.

Example 

The following listener wraps every record in an element that names its type and uid:

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

declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

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

final readonly class WrapRenderedRecordListener
{
  #[AsEventListener('my_extension/wrap-rendered-record')]
  public function __invoke(ModifyRenderedRecordEvent $event): void
  {
    $record = $event->getRecord();
    $event->setRenderedRecord(sprintf(
      '<div data-record="%s" data-uid="%d">%s</div>',
      htmlspecialchars($record->getFullType()),
      $record->getUid(),
      $event->getRenderedRecord(),
    ));
  }
}
Copied!

API 

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

Event to modify the rendered record output.

This can be used to alter the final HTML of a record (eg. content element), for example to render a debug wrapper around it.

getRenderedRecord()
Returns
string
setRenderedRecord(string $renderedRecord)

Set the rendered record's HTML.

Make sure to return escaped content if necessary.

param $renderedRecord

the renderedRecord

getRecord()
Returns
\TYPO3\CMS\Core\Domain\RecordInterface
getRequest()
Returns
\Psr\Http\Message\ServerRequestInterface