No announcement yet.

How to get the forum search to sort by 'Relevance' by default

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get the forum search to sort by 'Relevance' by default

    This must be a very simple edit somewhere but for the life of me I've spent hours trying to figure this w/o any results. Could someone kindly point me in the right direction?

    Basically this is what I'm looking for-

    When a user makes a search on the forums from the main page (not the advanced search page)

    The search results always defaults to sort by "Date - last update"

    I really need this to sort by "Relevance" by default ... is there any way to do this at all? What am I missing here?

    I suspect this must be a very simple edit somewhere that I am totally missing here but I'm not entirely sure what it is...

    I'm running the latest vB 5.2.1

    Any help I can get regarding my issue here would be greatly appreciated! Many thx in advance

  • #2
    This would require code customisations to achieve, there is no way to do this in the default software.

    It would be worth asking at, the modification and customisation site.

    TalkNewsUK - My vBulletin 5.6.3 Demo
    AdminAmmo - My Cloud Demo


    • #3
      You can do this via template hook. Create a template hook at footer_before_body_end hook location with the following template code.

      (function($) {
          $(window).on('load', function() {
              $('#searchForm').on('submit.searchform', function() {
                  var $searchJson = $('#header input[name="searchJSON"]'),
                      decodedJson = decodeURIComponent($searchJson.val()),
                  try {
                      parsedJson = $.parseJSON(decodedJson);
                      parsedJson.sort = 'relevance';
      If you don't know how to create a template hook, follow one of my mods in my signature below. The instructions should be similar.

      GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!


      • #4
        Glenn Vergara sweet! Thx a ton for that ... works a treat!


        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.