Issue Feature Closed

#35355Enhance searchable fields for livesearch

Anonymous 03/29/12, 11:30 updated 10/02/18, 12:42

Description

the list of fields that are being used by the livesearch toolbar in the upper right corner in the TYPO3 backend is filtered by the TCA configuration for that table.

in t3lib/search/class.t3lib_search_livesearch.php the searchable fields per table are being determined by the function extractSearchableFieldsFromTable($tableName):

399     // Traverse configured columns and add them to field array, if available for user.
400     foreach ((array) $GLOBALS['TCA'][$tableName]['columns'] as $fieldName => $fieldValue) {
401             // @todo Reformat
402             if (
403                    (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $tableName . ':' . $fieldName)) // does current user have access to the field
404                    &&
405                    ($fieldValue['config']['type'] != 'passthrough') // field type is not searchable
406                    &&
407                    (!preg_match('/date|time|int/', $fieldValue['config']['eval'])) // field can't be of type date, time, int
408                    &&
409                    (
410                         ($fieldValue['config']['type'] == 'text')
411                         ||
412                         ($fieldValue['config']['type'] == 'input')
413                    )
414               ) {
415                    $fieldListArray[] = $fieldName;
416               }
417      }
418
419      // Add special fields:
420      if ($GLOBALS['BE_USER']->isAdmin()) {
421              $fieldListArray[] = 'uid';
422              $fieldListArray[] = 'pid';
423      }

i suggest to enhance that $fieldListArray by a white list of fields for each table that is being determined in the configuration like this:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['content'] = 'tt_content';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['content']['searchableFields'] = 'uid,title,CType,list_type';

the first line is already in the core, enabling the mapping of ‘#content:1234’ to a search request limited to only tt_content and the value 1234.

the second line would be new and enabling the backend user to search for certain plugins, a task that i would like to do in a simple way. searching for tt_news is due to historical reasons a little different since the value for list_type is 9, but for most of the plugins i could use ‘#content:seminars_pi’ to get a list of all seminar plugins.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.