ModifyDatabaseQueryForRecordListingEvent

New in version 12.0: This event has been introduced to replace the following removed hooks:

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable']

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList']['modifyQuery']

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList']['makeSearchStringConstraints']

This event allows to alter the QueryBuilder SQL statement before a list of records is rendered in record lists such as the List module or an element browser.

Example

Registration of the event in your extension's Services.yaml:

EXT:my_extension/Configuration/Services.yaml
MyVendor\MyExtension\Backend\View\ModifyDatabaseQueryForRecordListingEvent:
    tags:
        - name: event.listener
          identifier: 'my-extension/backend/modify-database-query-for-record-list'

The corresponding event listener class:

EXT:my_extension/Classes/Backend/View/ModifyDatabaseQueryForRecordListingEventListener.php
use TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent;

final class ModifyDatabaseQueryForRecordListingEventListener
{
    public function __invoke(ModifyDatabaseQueryForRecordListingEvent $event): void
    {
        $queryBuilder = $event->getQueryBuilder();
        // Do something
        $event->getQueryBuilder($queryBuilder);
    }
}

API

class TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent

Use this Event to alter the database query when loading content for a page (usually in the list module) before it is executed.

getQueryBuilder()
Return type

TYPO3\CMS\Core\Database\Query\QueryBuilder

setQueryBuilder(TYPO3\\CMS\\Core\\Database\\Query\\QueryBuilder $queryBuilder)
Parameters
  • $queryBuilder (TYPO3\CMS\Core\Database\Query\QueryBuilder) -- the queryBuilder

getTable()
Return type

string

getPageId()
Return type

int

getFields()
Return type

array

getFirstResult()
Return type

int

getMaxResults()
Return type

int

getDatabaseRecordList()
Return type

TYPO3\CMS\Backend\RecordList\DatabaseRecordList