Lack of interest Search system requires keywords or user

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.

Rasmus Vind

Well-known member
I am building my own content type which has a lot of attributes. Attributes which I am not comfortable with swarming my node view page with, but would rather put in the dedicated search page. Unfortunately I have come to find a severe limitation of the search page. The search adapters is a genius idea and it satisfies everything I need and will need, but I have a problem with the controller XenForo_ControllerPublic_Search. It requires that the user either enters a username or keywords. This is the same no matter the content type you search in as it's in the controller and not the search_handler_class for each of XenForo's own content types.
I can understand that the "Search Everything" has this requirement as it's totally up to you, but for my own content type, why must I be limited by this? I have 10-20 different ways to reduce the result set of my content type. The user may not wish to reduce by username or keywords.

I would suggest that this line:
PHP:
if ($input['keywords'] === '' && empty($constraints['user']))
        {
            // must have keyword or user constraint
            return $this->responseError(new XenForo_Phrase('please_specify_search_query_or_name_of_member'));
        }
Is only applied for "Search Everything" and a similar error is returned by each of XenForo's own search_handler_class types (if you really want it there).

This suggestion is easy to implement and gives addon developers more power while the existing functionality remains completely the same.
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
I have been experimenting with commenting out the above line. Everything worked except for "Search Again". I have narrowed the issue down to XenForo_Route_Prefix_Search where the buildLink function looks as follows:
PHP:
    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        // add items to allow search to be repeated; query is checked to ensure user can view
        if ($data && !empty($data['search_query']))
        {
            if (!empty($data['search_query'])) { $extraParams['q'] = $data['search_query']; }
            if (!empty($data['search_type'])) { $extraParams['t'] = $data['search_type']; }
            if (!empty($data['search_order'])) { $extraParams['o'] = $data['search_order']; }
            if (!empty($data['search_grouping'])) { $extraParams['g'] = $data['search_grouping']; }
            if (!empty($data['search_constraints'])) { $extraParams['c'] = json_decode($data['search_constraints'], true); }
        }

        return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'search_id');
    }

This means that the "Search Again" link will only work if the user entered a search query. Another limitation.
 
Back
Top Bottom