ModifyRecordsAfterFetchingContentEvent

New in version 13.0: This event serves as a more powerful replacement for the removed $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'] hook.

The PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\ModifyRecordsAfterFetchingContentEvent allows to modify the fetched records next to the possibility to manipulate most of the options, such as slide. Listeners are also able to set the final content and change the whole TypoScript configuration, used for further processing.

Example

EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Frontend\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\ContentObject\Event\ModifyRecordsAfterFetchingContentEvent;

#[AsEventListener(
    identifier: 'my-extension/my-event-listener'
)]
final class MyEventListener
{
    public function __invoke(ModifyRecordsAfterFetchingContentEvent $event): void
    {
        if ($event->getConfiguration()['table'] !== 'tt_content') {
            return;
        }

        $records = array_reverse($event->getRecords());
        $event->setRecords($records);
    }
}

New in version 13.0: The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, you can also register an event listener via the Configuration/Services.yaml file. Have a look into the section Implementing an event listener in your extension.

API

class TYPO3\CMS\Frontend\ContentObject\Event\ModifyRecordsAfterFetchingContentEvent

Event which is fired after ContentContentObject has pulled records from database.

Therefore, allows listeners to completely manipulate the fetched records, prior to being further processed by the content object.

Additionally, the event also allows to manipulate the configuration and options, such as the "value" or "slide".

getRecords()
Return type

array

setRecords(array $records)
Parameters
  • $records (array) -- the records

getFinalContent()
Return type

string

setFinalContent(string $finalContent)
Parameters
  • $finalContent (string) -- the finalContent

getSlide()
Return type

int

setSlide(int $slide)
Parameters
  • $slide (int) -- the slide

getSlideCollect()
Return type

int

setSlideCollect(int $slideCollect)
Parameters
  • $slideCollect (int) -- the slideCollect

getSlideCollectReverse()
Return type

bool

setSlideCollectReverse(bool $slideCollectReverse)
Parameters
  • $slideCollectReverse (bool) -- the slideCollectReverse

getSlideCollectFuzzy()
Return type

bool

setSlideCollectFuzzy(bool $slideCollectFuzzy)
Parameters
  • $slideCollectFuzzy (bool) -- the slideCollectFuzzy

getConfiguration()
Return type

array

setConfiguration(array $configuration)
Parameters
  • $configuration (array) -- the configuration