Lack of interest 3rd parameter to \XF\Finder\Phrase::searchText : $prefixMatch = false

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

DragonByte Tech

Well-known member
So I am currently building an add-on that uses the phrase system to save product titles, and I am creating another page that lists downloads belonging to those products, using the product title to construct the list.

Example:
1512399518589.webp

This page is paginated, so I can't use the in-line filtering option, it needs to run an actual search, and in order to search product titles I have to do this:

PHP:
        if (strlen($filter['text']))
        {
            $downloadFinder->Product->MasterTitle->searchText($filter['text']);
        }

This effectively makes the "prefix" checkbox useless, but I can't turn it off from the filter_macros template. Therefore, I propose a change to \XF\Finder\Phrase::searchText that transforms the function into the following:

PHP:
    public function searchText($match, $caseSensitive = false, $prefixMatch = false)
    {
        if ($match)
        {
            $expression = 'phrase_text';
            if ($caseSensitive)
            {
                $expression = $this->expression('BINARY %s', $expression);
            }

            $this->where($expression, 'LIKE', $this->escapeLike($match, $prefixMatch ? '?%' : '%?%'));
        }

        return $this;
    }
Doing this should have no negative impact on existing code anywhere in XF or 3rd party products, and allows the prefix checkbox in the filter macro to do its job.

In addition, it would probably also be beneficial if there was an optional argument (default true) that let you turn off the prefix checkbox, just in case someone wanted to turn it off for whatever reason. Couldn't hurt, right? :P

Thank you for your time.


Fillip
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Top Bottom