AfterRecordIsRenderedEvent 

The PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\AfterRecordIsRenderedEvent is fired by the CONTENT and RECORDS content objects after each single record is rendered. A listener reads the HTML with getRenderedRecord() and replaces it with setRenderedRecord() , for example to wrap the record in markup of its own. Whatever a listener writes goes into the page as it is, so escape the parts that come from the record.

This event covers the records that TypoScript renders, for example through styles.content.get. For the records that Fluid renders, use ModifyRenderedRecordEvent, which this event is the counterpart of.

getRecord() usually returns a resolved record. Where TYPO3 cannot resolve the row, it returns a RawRecord with the unprocessed row instead. A custom select.selectFields that leaves out a system field, such as the language or the workspace field, has that effect.

TYPO3 skips the event entirely for a table without TCA, and for a row whose type field a custom select.selectFields left out. No record object can be built in those cases, and the rendered record stays as it is.

Example 

The following listener wraps every content element in an element that names its uid, and leaves the records of other tables alone:

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\Frontend\ContentObject\Event\AfterRecordIsRenderedEvent;

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

API 

final class AfterRecordIsRenderedEvent
Fully qualified name
\TYPO3\CMS\Frontend\ContentObject\Event\AfterRecordIsRenderedEvent

Event which is fired after the CONTENT or RECORDS content object has rendered a single record, allowing listeners to modify the rendered content of the record.

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