XF 2.1 xf_search table

Ozzy47

Well-known member
So I had a look in the file XF/Pub/Controller/Search.php and I am trying to figure out why when a user searches for something, and there are no results, the search is not stored in the xf_search table. It only stores a search in there if results are found.
 
What I ultimately would like to do is store that info in my own table, but I need to know how to overcome the problem of not saving the empty search.
 
To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
 
Well this is for the default XF search.

I had a look through those, but still can not figure out where to stop the system from not logging a search if the results are empty.

I would like to log empty results so admins can see what is being searched for on their sites, so if they keep seeing certain keywords searched for with no results they can add content to the site pertaining to those keywords.
 
Extend XF\Repository\runSearch(), get the keywords with $query->getKeywords(), call parent and check $search, do your logging if it's null and then return the $search.
 
Last edited:
Back
Top Bottom