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

Lack of interest Admin quick search relevancy


Well-known member
Not sure if bug or not.
I've noticed that the admin quick search gives not so relevant results at times.

If you will search the word: "message", in order to find that template, it won't show up in the results. Instead, you'll see other template results which contain that word.
I think that template name which start with that word, would be more relevant than strings that have the word in the middle/end.
You can test the same with the word "post".


XenForo developer
Staff member
Relevancy isn't something that we even attempt to do. As said, matching results are simply listed alphabetically. Relevancy (of some form, given that we're just doing a "like" search) would have to be a suggestion... so I'll just move this.


Well-known member
Guess it won't be fixed in the near future, so I've fixed that for myself.
if anyone interested, the code below will add relevancy for templates search:

public function getEffectiveTemplateListForStyle($styleId, array $conditions = array(), $fetchOptions = array())
    $whereClause = $this->prepareTemplateConditions($conditions, $fetchOptions);
    $limitOptions = $this->prepareLimitFetchOptions($fetchOptions);

    $titleRelevancy = '';
        $titleRelevancy = '(CASE WHEN template.title LIKE \''.$conditions['title'].'%\' THEN 0 ELSE 1 END),';

    return $this->_getDb()->fetchAll($this->limitQueryResults('
        SELECT template_map.template_map_id,
            template_map.style_id AS map_style_id,
            addon.addon_id, addon.title AS addonTitle,
            IF(template.style_id = 0, \'default\', IF(template.style_id = template_map.style_id, \'custom\', \'inherited\')) AS template_state,
            IF(template.style_id = template_map.style_id, 1, 0) AS canDelete
        FROM xf_template_map AS template_map
        INNER JOIN xf_template AS template ON
            (template_map.template_id = template.template_id)
        LEFT JOIN xf_addon AS addon ON
            (addon.addon_id = template.addon_id)
        WHERE template_map.style_id = ?
            AND ' . $whereClause . '
        ORDER BY ' . $titleRelevancy . ' CONVERT(template_map.title USING utf8)
    ', $limitOptions['limit'], $limitOptions['offset']), $styleId);