1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Search system requires keywords or user

Discussion in 'Closed Suggestions' started by Ralle, Jun 13, 2015.

  1. Ralle

    Ralle Active 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.
     
  2. Ralle

    Ralle Active Member

    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.
     

Share This Page