BeforeSearchInDatabaseRecordProviderEvent
New in version 12.1
The TYPO3 backend search (also known as "Live Search") uses the
\TYPO3\
to search
for records in database tables, having search
configured in TCA.
In some individual cases it may not be desirable to search in a specific table.
Therefore, the PSR-14 event
\TYPO3\
is available, which allows to exclude / ignore such tables by adding them
to a deny list. Additionally, the PSR-14 event can be used to restrict the
search result on certain page IDs or to modify the search query altogether.
Example
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Search\Event\BeforeSearchInDatabaseRecordProviderEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(
identifier: 'my-extension/before-search-in-database-record-provider',
)]
final readonly class MyEventListener
{
public function __invoke(BeforeSearchInDatabaseRecordProviderEvent $event): void
{
$event->ignoreTable('my_custom_table');
}
}
New in version 13.0
The PHP attribute \TYPO3\
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.
API
- class BeforeSearchInDatabaseRecordProviderEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Search\ Event\ Before Search In Database Record Provider Event
PSR-14 event to modify the incoming input about which tables should be searched for within the live search results. This allows adding additional DB tables to be excluded / ignored, to further limit the search result on certain page IDs or to modify the search query altogether.