We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hi,
    is there a parameter for Advsearch like it was &advSearch for AjaxSearch?

    I mean the option to search: oneword, allword, exactphrase?

    Thanks,
    Alessandro
      TilliLab | MODX Ambassador
      website
      • 5811
      • 1,717 Posts
      With AdvSearch, You don't need a parameter like &advSearch.

      To understand why, click on the help button near the search form or follow this link and look at the chapter "Query syntax"

      Or play with this demo page : http://www.revo.wangba.fr/index.php?id=120
      • Hi, and thanks for your reply,
        I had already seen your demo page, but actually I'm facing a customer quite annoying...he doesn't want so much power smiley

        I could resolve with a "queryhook" so that I transform the query search with AND operator between different words, could it be a solution?

          TilliLab | MODX Ambassador
          website
          • 5811
          • 1,717 Posts
          I could resolve with a "queryhook" so that I transform the query search with AND operator between different words, could it be a solution?
          No, you can't use queryHook to change the searchString.
          The queryHook is used only to modify the where clause of the sql request, by adding new filters. Not by modifying the string searched.
          • Thanks,
            I solved modifying class "advsearchutil.class.php":
            the main problem was when the user looked for phrase with single character word,
            ie: "have a nice day"

            in the advsearchutil.class.php I made it change a with " AND "...
            I hope to remember it when I'll update!

            I know I know...it sounds like a dirty workaround... smiley
              TilliLab | MODX Ambassador
              website
              • 39177
              • 22 Posts
              Any chance your could post your edit. I am having the exact same issue!
              • Hi,
                it's quite a old post and I don't use it anymore... anyway I found the modified file.
                Please note that it was used with an old version of advsearch 1.0 RC2 (I think) and also I'm not sure this is a safe solution, anyway:

                public function sanitizeSearchString($searchString) {
                 
                       if (!empty($searchString)) {
                 
                           //  remove "'"
                 
                           $searchString=strtr($searchString,"'"," ");
                 
                           $searchStringArray = explode(' ',$searchString);
                 
                           //print_r($searchStringArray);
                 
                           $searchStringArray = array_map("strip_tags",$this->modx->sanitize($searchStringArray, $this->modx->sanitizePatterns));
                 
                   // change single chars with "AND"
                 
                 
                           foreach($searchStringArray as $word2) {
                 
                               if (strlen($word2) < 3) {
                 
                           $my_var[]=' AND ';                      
                 
                           } else $my_var[]=$word2;
                 
                           }
                 
                           $searchString = implode(' ', $my_var);
                 
                   //      $searchString = implode(' ', $searchStringArray);


                Another user wrote me some time ago that he got the following error:

                "Inconsistent or invalid query".

                And he solved this way:

                - wrapped the query string with quotes prior submit using simple jQuery call.
                - hacked 'advsearch.class.php' to accept minchars=1 for a query string

                Hope you make it work smiley
                  TilliLab | MODX Ambassador
                  website
                  • 39177
                  • 22 Posts
                  Thanks for posting Tillilab!

                  This didn't work for Advsearch 1.01 and returned a "Inconsistent or invalid query" message.

                  Think I may abandon for Splittingreds SimpleSearch which has a phrase matching option.
                    • 39177
                    • 22 Posts
                    Nope turns out Simple search does not support TV searches so that a no go!

                    coroico if you are reading this pretty please can you suggest a route to forcing phrase matching!

                    Thanks!