[TYPO3-english] Improve Backend search (list view)

redacted user chris at bessei-it.eu
Sat Nov 28 11:31:25 CET 2015


Hi,

I found a workaround, which is enough for the moment:

Hook into
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray']
which calls makeQueryArray_post
Code:   
public function makeQueryArray_post(&$queryParts, $parentObject, $table,
$id, $addWhere, $fieldList, $_params)
    {
        if ($table === "fe_users" && !empty($parentObject->searchString)) {
            $searchTokens = String::multiExplode(array(" ", ",", ":",
"."), trim($parentObject->searchString));
            if (count($searchTokens) == 2) {
                /** @var DatabaseConnection $db */
                $db = $GLOBALS["TYPO3_DB"];
                $where = trim($queryParts["WHERE"]);
                //Last character is a closing bracket
                if (substr($where, -1) === ")") {
                    //Remove last closing bracket to add another search
condition
                    $where = substr($where, 0, -1);
                    //Build Fulltext search
                    $where .= " OR MATCH(first_name,last_name) "
                        . "AGAINST('+" . $db->quoteStr($searchTokens[0],
$table)
                        . "* +"
                        . $db->quoteStr($searchTokens[1], $table)
                        . "*' IN BOOLEAN MODE)";
                    //Add removed bracket
                    $where .= ")";
                    $queryParts["WHERE"] = $where;
                }
            }
        }
    }

Code auf Pastebin: http://pastebin.com/XDi3dJuG

Additionally I opened a feature request for another Hook/Signal in
makeSearchString:
https://forge.typo3.org/issues/71911

If anyone has a better solution please let me know!

Regards,
Chris



Am 2015-11-27 um 13:34 schrieb redacted user:
> Dear List,
>
> I currently try to improve the backend search field to achieve the
> following:
> Search a user from fe_users by first_name + last_name. Since they are
> stored in different columns TYPO3 can't find the user by default.
>
> E.g: Search term "Lisa Mair" where Lisa is stored in the first_name
> column and Mair in the last_name column.
> I could abuse the name column to store the full name, but then something
> like "Mair Lisa" and "Mair,Lisa" wouldn't work.
>
> Is there a hook/signal slot for the search field so I can add my own
> search conditions?
>
> Thanks for your help!
>
> Regards,
> Chris
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list