Feature: #99033 - Add table filter for backend search
See forge#99033
Description
The TYPO3 backend search (aka "Live Search") is using the
\TYPO3\
to search
for records in database tables, having search
configured in TCA.
In some individual cases, it may not be desired to search in a certain table.
Therefore, the new event \TYPO3\
has been introduced, which allows to exclude / ignore such tables by adding them
to a deny list. Additionally, the new PSR-14 event can be used to further
limit the search result on certain page IDs or to modify the search query
altogether.
The event features the following methods:
get
: Returns the page ids to search inSearch Page Ids () set
: Allows to define page ids to search inSearch Page Ids () get
: Returns theSearch Demand () Search
, used by the live searchDemand set
: Allows to set a customSearch Demand () Search
objectDemand ignore
: Allows to ignore / exclude a table from the lookupTable () set
: Allows to overwrite the ignored tablesIgnored Tables () is
: Returns whether a specific table is ignoredTable Ignored () get
: Returns all tables to be ignored from the lookupIgnored Tables ()
Registration of the event in your extension's Services.
:
MyVendor\MyPackage\EventListener\BeforeSearchInDatabaseRecordProviderEventListener:
tags:
- name: event.listener
identifier: 'my-package/before-search-in-database-record-provider-event-listener'
The corresponding event listener class:
use TYPO3\CMS\Backend\Search\Event\BeforeSearchInDatabaseRecordProviderEvent;
final class ModifyEditFileFormDataEventListener
{
public function __invoke(BeforeSearchInDatabaseRecordProviderEvent $event): void
{
$event->ignoreTable('my_custom_table');
}
}
Impact
It is now possible to ignore specific tables from the backend search using
the new PSR-14 event Before
. The event
also allows to adjust the page IDs to search in as well as to modify the
corresponding Search
object.