Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • 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 www.vbulletin.org, the modification and customisation site.
    MARK.B | vBULLETIN SUPPORT

    TalkNewsUK - My vBulletin 5.5.6 Demo
    AdminAmmo - My Cloud Demo

    Comment


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

      Code:
      <script>
      (function($) {
          $(window).on('load', function() {
              $('#searchForm').on('submit.searchform', function() {
                  var $searchJson = $('#header input[name="searchJSON"]'),
                      decodedJson = decodeURIComponent($searchJson.val()),
                      parsedJson;
      
                  try {
                      parsedJson = $.parseJSON(decodedJson);
                      parsedJson.sort = 'relevance';
                      $searchJson.val(JSON.stringify(parsedJson));
                  }
                  catch(e){}
                  
              });
          });
      })(jQuery);
      </script>
      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!

      Comment


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

        Comment

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