Feature #106333
openTCA-Table: Functionality to add custom filter to the table
0%
Description
Hi,
I don't know whether I've missed something but I have checked the documentation in https://docs.typo3.org/m/typo3/reference-tca/12.4/en-us/Ctrl/Index.html and seen nothing about building custom filter for a TCA-Table. I've checked the documentation for `ctrl` and `columns`, but nothing about adding filter to the table (only for form). If there is already a way, kindly point me in the right direction
TYPO3 version = v12.4.26
Suppose I have a SQL-Table with column `verified` (TINYINT. Value is either 1 or 0), I would like to be able to filter the entries in the TCA-Table of said SQL-Table by `verified` column (e.g. as Checkbox or Select field on the table header). Currently I can only filter by text through the main filter, but I also want to filter by non-text columns
Updated by Garvin Hicking 6 days ago
Sadly I know of no extension which integrates this to the "normal" record list, but technically it should be possible, so maybe digging for something like that in the extension repository could be fruitful?
The "DB Check" -> "Full search" backend module of EXT:lowlevel allows do define very specific filter rules to find record lists and save these as presets. However that might be a bit complex for editors.
There is a PSR-14 Event ModifyDatabaseQueryForRecordListingEvent (see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-98490-PSR-14EventToAlterTheRecordsRenderedInRecordListings.html) that you can use to conditionally add more WHERE conditions to your record list, by evaluating the table name. Then however you will never be able to edit/view rows that have 'verfied' not set, so that might not be what you're actually looking for?
Updated by Garvin Hicking 5 days ago
- Status changed from New to Accepted
I've conferred with Oli Bartsch and Georg Ringer. We all believe this would be something that is desirable. I was made aware of https://github.com/TYPO3GmbH/querybuilder which provided such a feature in earlier versions. I do think we would need to put a lot of thinking into this feature and what it should provide in which way (with our without presets? Presets managed by editors or only integrators?). This all has a larger impact on the UI and UX. And it needs to be well-maintainable if it becomes part of the TYPO3 core.
Personally, I've missed this a couple of times too, but usually provided custom backend modules then (using `<f:be.tablelist>` in a custom module).
Thanks for bringing this up here, and let's see if it gains traction! This wouldn't be a small feature to implement, so it would take effort.
Updated by Jason Christian 5 days ago
ยท Edited
Thank your for confirming as well. My idea is that we can add it in TCA settings to make it easier for editors to implement them
Somewhere along in
$GLOBALS['TCA'][<tablename>]['columns'][<colname>]['tablefilter']
[
'type' => 'checkbox', # mapped to 1 or 0. WHERE verified = 0|1
'label' => 'Verified'
]
...
[
'type' => 'select',
'label' => 'Type',
'options' => [ ['Type 1', 'type_1'], ['Type 2', 'type_2'], .... ] # or we can emit the `options` and it will be populated with all possible values from DB for that column
]
...
[
'type' => 'text',
'label' => 'Search Term',
]
In DatabaseRecordList.php probably the simplest way is to obtain these filter configurations, build HTML representations of it, and put it in `getTable()` as a new form. I am looking at RecordSearchBox to see how they can filter by text, but I haven't found the exact query builder code for it.
Updated by Garvin Hicking 1 day ago
That sounds interesting! I am not too sure we should enhance the TCA for this kind of filters. Instead, something along how the RichttextEditor is configured might be better. So have a seperate place where to define filters.
I actually believe setting this with TypoScript (and not a seperate YAML file or so) would be beneficial. This way, Page and User TS Config could be created to individually apply filters both to usergroups, single users, and also even make specific filters available to specific pages.
So then you could do nice stuff like this:
- In SysFolder A you setup News records and you allow filtering by title and category, very plain
- In SysFolder B you could setup another filter that applies to the same News model (different records though) and you could filter those by different criteria, like an author start/enddate
Since the FormEngine display of records is bound to the page tree, both evaluating TS config and Page TS config should fall into place quite nicely.
What do you think?